Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I'm not getting any errors, but this script isn't working?

I'm kinda new to tweening. For some reason, my script has no errors. But just doesn't work.

Script:

plr = game.Players.LocalPlayer
game.Players.PlayerAdded:connect(function()
	if script.Parent.Position == UDim2.new(-1, 0, 0, 0) then
		script.Parent:TweenPosition(UDim2.new(0, 0, 0, 0))
	end
end)

1 answer

✓ Accepted answer

Credit to DataStore for pointing out my initial error whilst writing this answer


The PlayerAdded event doesn't work in localscripts! You need to change your code so that this tweens the gui from the server - and index the gui from the player's PlayerGui.


game.Players.PlayerAdded:connect(function(plr)
	plr:WaitForChild('PlayerGui') --Wait for the player's playergui to load
	local gui = plr.PlayerGui.ScreenGui --INDEX THE GUI HERE PLEASE
	--The conditional is kind of redundant. Since the player only joins once
	script.Parent:TweenPosition(UDim2.new(0,0,0,0))
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.