Welcome to the Forums!
Join thousands of other Roblox members with a free account.
Create Forum Account

Error for "Unable to cast to dictionary"

  • This website was created by Roblox members to replace the official forums (because Roblox shut them down) Join us if you like Roblox!

SqueakApple

New Member
Reputation: 0 / 0 / 0
Feb 20, 2021
3
2
3
Roblox
Squeak_apple
Lua:
local Campart = game.Workspace.CamPart

local TweenService = game:GetService("TweenService")

local camera = game.Workspace.Camera
local studio = game.Workspace


game.ReplicatedStorage.HatchEgg.OnClientEvent:Connect(function(pet)
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CFrame = Campart.CFrame
    
    for i = 1, 50, 1 do
        game.Workspace.Egg.Size = game.Workspace.Egg.Size + Vector3.new (0.1,0.1,0.1)
        wait(0.01)
    end
    
    
    
    local explosion = Instance.new("Explosion")
    explosion.BlastRadius = 10
    explosion.BlastPressure = 0
    explosion.Position = studio.Egg.Position
    explosion.ExplosionType = Enum.ExplosionType.NoCraters
    explosion.DestroyJointRadiusPercent = 0
    
    explosion.Parent = studio.Egg
    
    
    
    studio.Egg.Transparency = 1
    
    
    local petClone = pet:Clone()
    
    for i, v in pairs(petClone:GetChildren()) do
        if v:IsA("BasePart") then
            v.Anchored = true
        end
    end
    for i, v in pairs(studio.Egg:GetChildren()) do
        if v:IsA("ParticleEmitter") then
            v.Enabled = true
        end
    end
    
    
    petClone.Parent = studio
    petClone:SetPrimaryPartCFrame( CFrame.new(studio.Egg.Position,studio.CamPart.Position))
    
    local tweenInfo = TweenInfo.new(
        2,
        Enum.EasingStyle.Bounce,
        Enum.EasingDirection.Out,
        0,
        false,
        0
    )
    
    local tween = TweenService:Create(camera, tweenInfo, {CFrame = CFrame.new(petClone.PrimaryPart.Position + (petClone.PrimaryPart.CFrame.lookVector * 5) + Vector3.new(0,0.75,0)),petClone.PrimaryPart.Position})
    
    tween:Play()
    
    wait(5)
    
    for i, v in pairs(studio.Confetti:GetChildren()) do
        if v:IsA("ParticleEmitter") then
            v.Enabled = false
        end
    end
    
    
    camera.CameraType = Enum.CameraType.Custom
    studio.Egg.Transparency = 0
    studio.Egg.Size = Vector3.new(3.399, 4.953, 1.956)
    petClone:Destroy()
    
end)
 

CallMeKY

Moderator
Ultra
Reputation: 6 / 0 / 0
Feb 25, 2018
1,496
42
609
113
Maine, USA
Roblox
CallMeKY
Discord
CallMeKY#5012
Lua:
local Campart = game.Workspace.CamPart

local TweenService = game:GetService("TweenService")

local camera = game.Workspace.Camera
local studio = game.Workspace


game.ReplicatedStorage.HatchEgg.OnClientEvent:Connect(function(pet)
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CFrame = Campart.CFrame
   
    for i = 1, 50, 1 do
        game.Workspace.Egg.Size = game.Workspace.Egg.Size + Vector3.new (0.1,0.1,0.1)
        wait(0.01)
    end
   
   
   
    local explosion = Instance.new("Explosion")
    explosion.BlastRadius = 10
    explosion.BlastPressure = 0
    explosion.Position = studio.Egg.Position
    explosion.ExplosionType = Enum.ExplosionType.NoCraters
    explosion.DestroyJointRadiusPercent = 0
   
    explosion.Parent = studio.Egg
   
   
   
    studio.Egg.Transparency = 1
   
   
    local petClone = pet:Clone()
   
    for i, v in pairs(petClone:GetChildren()) do
        if v:IsA("BasePart") then
            v.Anchored = true
        end
    end
    for i, v in pairs(studio.Egg:GetChildren()) do
        if v:IsA("ParticleEmitter") then
            v.Enabled = true
        end
    end
   
   
    petClone.Parent = studio
    petClone:SetPrimaryPartCFrame( CFrame.new(studio.Egg.Position,studio.CamPart.Position))
   
    local tweenInfo = TweenInfo.new(
        2,
        Enum.EasingStyle.Bounce,
        Enum.EasingDirection.Out,
        0,
        false,
        0
    )
   
    local tween = TweenService:Create(camera, tweenInfo, {CFrame = CFrame.new(petClone.PrimaryPart.Position + (petClone.PrimaryPart.CFrame.lookVector * 5) + Vector3.new(0,0.75,0)),petClone.PrimaryPart.Position})
   
    tween:Play()
   
    wait(5)
   
    for i, v in pairs(studio.Confetti:GetChildren()) do
        if v:IsA("ParticleEmitter") then
            v.Enabled = false
        end
    end
   
   
    camera.CameraType = Enum.CameraType.Custom
    studio.Egg.Transparency = 0
    studio.Egg.Size = Vector3.new(3.399, 4.953, 1.956)
    petClone:Destroy()
   
end)
It looks like you're closing the constructor before you set the LookAt vector, shifting the second to last parenthesis to the right of the LookAt should fix it.

Lua:
{CFrame = CFrame.new(petClone.PrimaryPart.Position + (petClone.PrimaryPart.CFrame.lookVector * 5) + Vector3.new(0, 0.75, 0), petClone.PrimaryPart.Position)})
 
  • Like
Reactions: SqueakApple