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

How to freeze Local player instead of freezing all Players?

Asked by
M9F 94
4 years ago
Edited 4 years ago

I'm trying to freeze a single player that steps on a platform but it freezes all players, I can't seem to get it working.

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
--testing
workspace.TestPad.Touched:Connect(function(hit)
     LocalPlayer.HumanoidRootPart.Anchored = true
end)
0
you cant use localplayer in a script, u can only use it in localscripts, this is how u would fix ur script: game.Workspace.TestPad.Touched:Connect(function(Hit) if Hit.Parent:FindFirstChild('Humanoid') then Hit.Parent.HumanoidRootPart.Anchored = true end end)  DEVLogos 8 — 4y
0
it is a localscript M9F 94 — 4y
0
it is supposed to be a script, i sent u a friend request if u need more assistance, the name is StudioLegacy, and by the way the script should be in serverscriptservice or workspace DEVLogos 8 — 4y
0
you cant use localplayer in a script, u can only use it in localscripts, this is how u would fix ur script DEVLogos 8 — 4y
0
Server scripts are unable to access LocalPlayer since they are ServerSided. This means they don't know who the LocalPlayer is. CaptainAlien132 225 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Server scripts can't use LocalPlayer since they are server sided and not client sided. Instead of using LocalPlayer.

We can find the player by using what put in the parentheses after the .Touched function.

Make sure this is in a server script in either the Workspace or ServerScriptService.

workspace.TestPad.Touched:Connect(function(hit) --Begin the function when the pad was touched
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then --If the part that touched the pad's parent (the player) has a humanoid then
        hit.Parent.HumanoidRootPart.Anchored = true --If it does then anchor the player 
    end
end)

If this helped then please accept the answer.

Ad

Answer this question