So this script is inside StarterGUI inside a GUI that has a text button, it is a script, not a local script, and it dosen't work anymore, can anyone help?
01 | --[[ |
02 |
03 |
04 | --]] |
05 | function Click() |
06 | script.Parent.Parent.Button.Text = "Teleporting..." |
07 | wait( 0.5 ) |
08 | script.Parent.Parent.Button.Text = "Teleporting." |
09 | wait( 0.5 ) |
10 | script.Parent.Parent.Button.Text = "Teleporting.." |
11 | wait( 0.5 ) |
12 | script.Parent.Parent.Button.Text = "Teleporting..." |
13 | wait( 0.5 ) |
14 | script.Parent.Parent.Button.Text = "Teleporting." |
15 | wait( 0.5 ) |
Make the script local. Server scripts can only access the GUI through RemoteEvents.
You need to use a local script to handle the MouseButton1Down
event and a server script to handle the change in the UpperTorso
's CFrame
. With that being said, you'll have to use a remote event to communicate the change. I also included a way to shorten your local script:
1 | --Server script |
2 |
3 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
4 | local Remote = Instance.new( "RemoteEvent" ) --create remote |
5 | Remote.Parent = ReplicatedStorage |
6 |
7 | Remote.OnServerEvent:Connect( function (player) |
8 | player.Character.UpperTorso.CFrame = CFrame.new( 0 ,. 5 , 4.7 ) |
9 | end ) |
01 | --Local script |
02 |
03 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
04 | local Remote = ReplicatedStorage:WaitForChild( "RemoteEvent" ) --wait for remote |
05 |
06 | script.Parent.MouseButton 1 Down:Connect( function () |
07 | local str = "Teleporting" |
08 | local length = str:len() |
09 | for i = 1 , 10 ,. 5 do |
10 | wait(. 5 ) |
11 | if str:len() < length + 3 then |
12 | str = str .. "." |
13 | script.Parent.Parent.Button.Text = str |
14 | else str = "Teleporting" |
15 | script.Parent.Parent.Button.Text = str |
16 | end |
17 | end |
18 | Remote:FireServer() |
19 | end ) |