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

Change walkspeed on touched event?

Asked by 5 years ago

Ok so basically i made a teleporting pad and rigged up with it is a gui that would cover the player's screen while teleporting, and i also want make it so the player can't move , i've tried but for some reason it just won't work

Here's the code


local tpTo = "TP2" local Players = game:GetService('Players') script.Parent.Touched:connect(function (hit) if hit.Parent:FindFirstChild('Humanoid') then local char = hit.Parent if Players:FindFirstChild(char.Name) then local plr = Players:FindFirstChild(char.Name) local gui = plr.PlayerGui.questchat.Teleport local human = hit.Parent.Humanoid gui:TweenSize(UDim2.new(1,0,1,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quint,0.25) wait(0.25) if script.Parent.Locked == false and script.Parent.Parent:FindFirstChild(tpTo).Locked == false then script.Parent.Locked = true script.Parent.Parent:FindFirstChild(tpTo).Locked = true local pos = script.Parent.Parent:FindFirstChild(tpTo) human.WalkSpeed = 0 char:moveTo(pos.Position) script.Parent.Locked = false script.Parent.Parent:FindFirstChild(tpTo).Locked = false end gui:TweenSize(UDim2.new(0,0,0,0),Enum.EasingDirection.In,Enum.EasingStyle.Quint,1) human.WalkSpeed = 16 end end end)

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Anything GUI related, put it under an OnClientEvent of RemoteEvent, and fire the remote to the client. You’re trying to modify PlayerGui on the server, which is a big no no.

Remote.OnClientEvent:Connect(function()
    -- localscript, put your tween position code here.
end)

Server script with your touched event:

Remote:FireClient(plr)
0
I know about that, i still haven't figured my way around remote events, still a noobie to lua and learning new things everyday. Anyways any idea how to change the movespeed? misterdimacugut 11 — 5y
Ad

Answer this question