So I am trying to make a ui tween whenever a local player joins but the function doesn’t fire when a player joins I’ve also tried trouble shooting by printing but it doesn’t print anything. here is the script:
local Play = script.Parent
local player = game:GetService("Players")
local localplayer = player.LocalPlayer
localplayer.CharacterAdded:Connect(function()
print("hi")
Play:TweenPosition(UDim2.new({0.188, 0},{0.262, 0}),
Enum.EasingDirection.Out,
Enum.EasingStyle.Elastic,
2,
false
)
end)
LocalScripts will only run if it’s a descendant of the player, the player’s character or ReplicatedFirst, is your LocalScript a descendant of any of those?
Im assuming your script is under a StarterGui which is added to PlayerGui when the player’s character spawns, meaning your code connects the event after the character spawns, what this means is that you don’t need to attach an event, you can simply tween it as the script is only added when the player spawns and is reset when the player respawns:
local Play = script.Parent
local player = game:GetService("Players")
local localplayer = player.LocalPlayer
Play:TweenPosition(UDim2.new({0.188, 0},{0.262, 0}), --no need to connect an event
Enum.EasingDirection.Out,
Enum.EasingStyle.Elastic,
2,
false
)