Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GUI Tweening won't work?

Asked by 9 years ago

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?

0
Where is this script located? DigitalVeer 1473 — 9y

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

Your Problem

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

How To Fix

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.

Code

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)

0
It didn't work. Grenaderade 525 — 9y
0
Make sure you're defining'gui' on line 6, as well as making this a serverscript in Workspace. Goulstem 8144 — 9y
Ad

Answer this question