I cannot seem to make the script check if the player's UserId is correct.
Here is my code:
local Players = game:GetService('Players')
local Player = Players.LocalPlayer
if script.Parent.PrimaryPart then
if Player.UserId == 171275787 then
for i, v in pairs(script.Parent:GetDescendants()) do
if v:IsA("BasePart") then
if v ~= script.Parent.PrimaryPart then
local wc = Instance.new("WeldConstraint",script.Parent.PrimaryPart)
wc.Name = "weld"
wc.Part0 = script.Parent.PrimaryPart
wc.Part1 = v
v.Anchored = false
v.CanCollide = false
v.Massless = true
end
end
end
script.putBehind.Disabled = false
end
end
Please help, Thanks

6 comments
is this in a localscript? Players.LocalPlayer is nil on server scripts
yeah, its probably a script, change it to a localscript.
what I'm trying to do doesn't work if its a local script so maybe there is another way to do it
is there a way I can do it with a server script?
no u can't localplayer is nil in a server script, you have to use game.Players.PlayerAdded for server scripts
don’t use UserId on LocalScript. even if it works, hackers can avoid it. if this is in a character you can use GetPlayerFromCharacter.