I'm making a Gui that tweens from one position to another by saying "/jobs" in chat.
GUI = script.Parent.JobsInfo.TextLabel Message = "/jobs" game.Players.PlayerAdded:connect(function(Player) Player.Chatted:connect(function(Message) print('Tween pls') GUI:TweenPosition(UDim2.new(0, -200, 0, 5),"Out", "Quad", 3, true) wait(1.5) GUI:TweenPosition(UDim2.new(0, 5, 0, 5), "Out", "Quad", 3, false) end) end)
Once I added the tween part, it didn't work. Help?
You never make a conditional for the Tweening to activate. So it's going to activate reguardless of what the player chats.
Also, I see this is in a gui. You shouldn't have the PlayerAdded
event inside of the client - e.g a GUi
Have an if statement
before the gui tweening to check if what the player said was equivilent to the preset 'Message' variable. Also, you shouldn't have the Message variable have the same identity of the parameter for your Chatted
event, they'll overlap.
Make a serverscript in workspace for the PlayerAdded
event, then index the gui from their PlayerGui with the Chatted
Event.
local message = "/jobs" game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(function(chat) if chat:lower() == message then local gui = plr.PlayerGui --Index the gui here! GUI:TweenPosition(UDim2.new(0, -200, 0, 5),"Out", "Quad", 3, true) wait(1.5) GUI:TweenPosition(UDim2.new(0, 5, 0, 5), "Out", "Quad", 3, false) end end) end)