Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I keep getting "Unable to cast to Dictionary" Error in my Egg Hatching script, what should I do?

Asked by 3 years ago

Here is code, error is at line 54, I followed tutorial and script is exact and I don't see problem with it either.

local  TweenService = game:GetService("TweenService")

local camera = game.Workspace.Camera
local studio = game.Workspace.Studio
game.ReplicatedStorage.HatchEgg.OnClientEvent:Connect(function(pet)
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CFrame = studio.CamPart.CFrame

    wait(0.5)

    for i = 1, 50, 1 do
        studio.Egg.Size = studio.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.Confetti:GetChildren()) do
        if v:IsA("ParticleEmitter") then
            v.Enabled = true
        end
    end

    petClone:SetPrimaryPartCFrame(CFrame.new(studio.Egg.Position,studio.CamPart.Position))

    petClone.Parent = studio

    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(8.426, 11.613, 5.717)
    petClone:Destroy()
end)

so what should I do.

0
Just a little tipp. I dont know if you did know about it, but you can make Particle emmiters emmit a certain amount of particles at once. This is really usefull for Confetti. ParticleEmitter:Emit(how many particles in here) esepek 103 — 3y
0
That is possible? thanks for great tip :) Sabailuridze 126 — 3y

1 answer

Log in to vote
0
Answered by
esepek 103
3 years ago
Edited 3 years ago

I guess the problem is that you are trying to add a Vector3 to a CFrame which aint possible. Also please try to make your code a bit more clean, especially at line 54 you got lots of things on 1 line. Also make sure to set camera to workspace.CurrentCamera and use a local script for camera tweening.

0
Thanks, I changed few things and removed Vector3, it works now :) Sabailuridze 126 — 3y
Ad

Answer this question