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

Handcuffs If statement not working? [CFrame]

Asked by 6 years ago
Edited 6 years ago

I made some Handcuffs that teleport a player when you click on them. But, For some odd reason It doesn't do ANYTHING. Here is the handcuffs LocalScript:




local prisons = game.Workspace.Prison:GetChildren() local RemoteEvent = game.ReplicatedStorage.SwitchToPrisoner script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() if mouse then if mouse.Target.Parent:isA("Accessory") then if (script.Parent.Parent.Head.Position - mouse.Target.Parent.Parent.Head.Position).magnitude <= 5 then -- Change "10" if you want to. This is the range of the arrest tool. The higher the number the longer the range you can arrest the player if game.Players[mouse.Target.Parent.Parent.Name].Team == "Criminals" then local char = mouse.Target.Parent.Parent local CriminalName = char.Name RemoteEvent:FireServer(CriminalName, char, prisons) end end end if mouse.Target.Parent.Humanoid then if mouse.Target:isA("Part") or mouse.Target:isA("UnionOperation") or mouse.Target:isA("MeshPart") then if game.Players[mouse.Target.Parent.Name].Team == "Criminals" then local char = mouse.Target.Parent local CriminalName = char.Name RemoteEvent:FireServer(CriminalName, char, prisons) char.HumanoidRootPart.CFrame = prisons[math.random(1,#prisons)].CFrame + Vector3.new(0,3,0) -- Same as this end end end end end) end)

It fires the remote event. Here is the "Server Sided Code":

local RemoteEvent = game.ReplicatedStorage.SwitchToPrisoner

RemoteEvent.OnServerEvent:Connect(function(player, CriminalName, char, prisons)
    if game.Players.LocalPlayer == CriminalName then

        char.HumanoidRootPart.CFrame = prisons[math.random(1,#prisons)].CFrame + Vector3.new(0,3,0)
    end

end)

Do you see any errors? Please let me know and answer me if you can.

0
put all your code in a code block.. awesomeipod 607 — 6y
0
Ok DragRacer31 7 — 6y
0
Why do you have game.Players.LocalPlayer in a serversided code? Put that value in a tuple argument. cmgtotalyawesome 1418 — 6y
0
How do you do that? DragRacer31 7 — 6y
View all comments (3 more)
0
replace game.Players.LocalPlayer with player the8bitdude11 358 — 6y
0
also, replace the + Vector3.new(0,3,0) with * CFrame.new(0,3,0) the8bitdude11 358 — 6y
0
Ok I will try that out. DragRacer31 7 — 6y

Answer this question