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

Tween and text don't want to work how to fix?

Hello there everyone, I'm trying to switch a gui whenever a value is different and it works fully! Except that it doesn't wanna change the text, doesn't set the correct position and doesn't want to tween. Can anyone help me? Ty!

(picture of my explorer) https://i.imgur.com/oG0TjW6.png

mvn = script.Parent.Parent.Parent.Parent.Parent.Parent.VehicleSeat
sensor = script.Parent.Parent.Parent.Parent.Parent.Parent.Destination.stopped

while true do
	wait(1)
	if sensor.Value == true then
		script.Parent.Parent.Visible = true
		script.Parent.Parent.Parent.Frame1.Visible = false
		script.Parent.Text = "Mind the gap between the train and platform!"
		script.Parent.Position = UDim2.new(0, 400, 0, 0)
		script.Parent:TweenPosition(UDim2.new(0, -700, 0,  0), "Out", "Linear", 7)
		wait(11)
		script.Parent.Text = "Welcome onboard AT' trains!"
		script.Parent.Position = UDim2.new(0, 400, 0, 0)
		script.Parent:TweenPosition(UDim2.new(0, -700, 0,  0), "Out", "Linear", 7)
		wait(13)
		script.Parent.Text = "Doors closing, please stand clear!"
		script.Parent.Position = UDim2.new(0, 400, 0, 0)
		script.Parent:TweenPosition(UDim2.new(0, -700, 0,  0), "Out", "Linear", 7)
		wait(11)
		script.Parent.Parent.Visible = false
		script.Parent.Parent.Parent.Frame1.Visible = true
	end
end

1 answer

Please change to LocalScript as using ServerScript will make the Gui of all players pop up when 1 player in the game clicked it. I changed some of the things in the script and I hope it helps.

Using LocalScript:

mvn = script.Parent.Parent.Parent.Parent.Parent.Parent.VehicleSeat
sensor = script.Parent.Parent.Parent.Parent.Parent.Parent.Destination.stopped

while true do
    wait(1)
    if sensor.Value == true then
        script.Parent.Parent.Visible = true
        script.Parent.Parent.Parent.Frame1.Visible = false
        script.Parent.Text = "Mind the gap between the train and platform!" -- To be honest, I have this problem currently too, and my script doesn't show any error. I don't think this is our problem, maybe it is roblox problem. Well, try deleting the ServerScript first then paste this script in a LocalScript, tell me if the text change after. Thanks!
        script.Parent.Position = UDim2.fromOffset(400, 0) -- Normally, I prefer using the "fromOffset" or "fromScale" function instead of "new" function
        script.Parent:TweenPosition(UDim2.fromOffset(-700,  0), "Out", "Linear", 7)
        wait(11)
        script.Parent.Text = "Welcome onboard AT' trains!"
        script.Parent.Position = UDim2.fromOffset(400, 0)
        script.Parent:TweenPosition(UDim2.fromOffset(-700,  0), "Out", "Linear", 7)
        wait(13)
        script.Parent.Text = "Doors closing, please stand clear!"
        script.Parent.Position = UDim2.fromOffset(400, 0)
        script.Parent:TweenPosition(UDim2.fromOffset(-700,  0), "Out", "Linear", 7)
        wait(11)
        script.Parent.Parent.Visible = false
        script.Parent.Parent.Parent.Frame1.Visible = true
    end
end

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