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.

7 comments

0

put all your code in a code block..

0

Ok

0

Why do you have game.Players.LocalPlayer in a serversided code? Put that value in a tuple argument.

0

How do you do that?

0

replace game.Players.LocalPlayer with player

0

also, replace the + Vector3.new(0,3,0) with * CFrame.new(0,3,0)

0

Ok I will try that out.