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?
--[[ --]] function Click() script.Parent.Parent.Button.Text = "Teleporting..." wait(0.5) script.Parent.Parent.Button.Text = "Teleporting." wait(0.5) script.Parent.Parent.Button.Text = "Teleporting.." wait(0.5) script.Parent.Parent.Button.Text = "Teleporting..." wait(0.5) script.Parent.Parent.Button.Text = "Teleporting." wait(0.5) script.Parent.Parent.Button.Text = "Teleporting.." wait(0.5) script.Parent.Parent.Button.Text = "Teleporting..." wait(0.5) script.Parent.Parent.Button.Text = "Teleporting." wait(0.5) script.Parent.Parent.Button.Text = "Teleporting.." script.Parent.Parent.Parent.Parent.Character.UpperTorso.CFrame = CFrame.new(0, 0.5, 4.7) -- Place ace location coordinates here! script.Parent.Parent.Button.Text = "Ready." wait(2) script.Parent.Parent.Button.Text = "Teleport" end script.Parent.MouseButton1Down:connect(Click)
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:
--Server script local ReplicatedStorage = game:GetService("ReplicatedStorage") local Remote = Instance.new("RemoteEvent") --create remote Remote.Parent = ReplicatedStorage Remote.OnServerEvent:Connect(function(player) player.Character.UpperTorso.CFrame = CFrame.new(0,.5,4.7) end)
--Local script local ReplicatedStorage = game:GetService("ReplicatedStorage") local Remote = ReplicatedStorage:WaitForChild("RemoteEvent") --wait for remote script.Parent.MouseButton1Down:Connect(function() local str = "Teleporting" local length = str:len() for i = 1,10,.5 do wait(.5) if str:len() < length + 3 then str = str .. "." script.Parent.Parent.Button.Text = str else str = "Teleporting" script.Parent.Parent.Button.Text = str end end Remote:FireServer() end)