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

I have a problem with tween info, (Unable to cast Dictionary to TweenInfo)?

Asked by 2 years ago
Edited 2 years ago

( i am a begginer at lua and just scripting in general it would be greatly appreciated if i was given some tips) i used tutorial to make this script its for blood drops when a player gets hit/damaged it is put in server script service and there is also a blood part which is the child of the script.

local healthPerDrop = 5
local dropLifeTime = 30
local dropSizeMin, dropSizeMax = 0.1, 2

local blood = script:WaitForChild("Blood")


local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Quint,Enum.EasingDirection.InOut)


game.Players.PlayerAdded:Connect(function(plr)

    plr.CharacterAdded:Connect(function(char)

        local humanoid = char:WaitForChild("Humanoid")


        local previousHealth = humanoid.Health

        humanoid.HealthChanged:Connect(function(newHealth)


            local healthDifference = previousHealth - newHealth

            previousHealth = newHealth

            if healthDifference < 0 then return end


            local numOfDrops = math.floor(healthDifference / healthPerDrop)

            local dropsFolder = Instance.new("Folder", workspace)

            for i = 1, numOfDrops do

                local dropSize = math.random(dropSizeMin * 10, dropSizeMax * 10) / 10

                local bloodDrop = blood:Clone()
                bloodDrop.Size = Vector3.new(0, 0, 0)


                local xPos = char.HumanoidRootPart.Position.X + math.random(-30, 30) / 10
                local yPos = char.LeftFoot.Position.Y - char.LeftFoot.Size.Y/2 + 0.05
                local zPos = char.HumanoidRootPart.Position.Z + math.random(-30, 30) / 10

                bloodDrop.Position = Vector3.new(xPos, yPos, zPos)

                bloodDrop.Parent = dropsFolder

                --this is where the problem is coming from
                tweenService:Create (bloodDrop, TweenInfo, {Size = Vector3.new(0.05, dropSize, dropSize)}) :Play()
            end


            wait(dropLifeTime)
            dropsFolder:Destroy()
        end)
    end)
end)

1 answer

Log in to vote
3
Answered by
appxritixn 2235 Moderation Voter Community Moderator
2 years ago

When using variables, capitalization matters!

On line 52, you attempt to use TweenInfo when creating the tween, when your variable is tweenInfo

Change

tweenService:Create (bloodDrop, TweenInfo, {Size = Vector3.new(0.05, dropSize, dropSize)}) :Play()

to

tweenService:Create (bloodDrop, tweenInfo, {Size = Vector3.new(0.05, dropSize, dropSize)}) :Play()
0
Thank you so much! it works now! Icy_limxz 14 — 2y
Ad

Answer this question