TweenService in a local script?

Hello! :wave:

I have just started learning to tween and I had found a tutorial to tween in a server script. Now the problem is, I want the tween in a local script, but if I put this code in a local script it doesn’t work anymore (and it doesn’t give any errors too)

Can someone explain me how I could make this server tween into a local tween or if its even possible?

Here is the script I have:

local part = script.Parent
local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(
	1, --Time the tween runs
	Enum.EasingStyle.Linear, --The Easing Style of the tween
	Enum.EasingDirection.Out, --The EasingDirection of the tween
	0, --How many times the tween repeats
	false, --if the tween will reverse
	0 --How long it takes until the tween starts
)

local tween = TweenService:Create(part, tweenInfo, {Color = Color3.fromRGB(0, 255, 0)})

script.Parent.Touched:Connect(function(hit)
	tween:Play()
	script.Parent.Color:Destroy()
end)

Thanks for reading this and hopefully you can help me :smile:

1 Like

If your using this in a local script, you need to relocate where the part is, and place the local script inside of StarterGui or smth. EX: Once placed in the local script and everything, change local part = script.Parent, to the actual parts location.

local part = game.Workspace.PartHere
local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(
	1, --Time the tween runs
	Enum.EasingStyle.Linear, --The Easing Style of the tween
	Enum.EasingDirection.Out, --The EasingDirection of the tween
	0, --How many times the tween repeats
	false, --if the tween will reverse
	0 --How long it takes until the tween starts
)

local tween = TweenService:Create(part, tweenInfo, {Color = Color3.fromRGB(0, 255, 0)})

script.Parent.Touched:Connect(function(hit)
	tween:Play()
	script.Parent.Color:Destroy()
end)

That still doesn’t do anything :pensive: