LocalScript in Handcuff tool.
local Officer = game.Players.LocalPlayer script.Parent.Handle.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local arrestedworkspaceplr = workspace[hit.Parent.Name] local arrestedplayer = game.Players:GetPlayerFromCharacter(arrestedworkspaceplr) game.ReplicatedStorage.Police.CloneHandcuffGui:FireServer(tostring(arrestedplayer)) end end)
ServerScript in ServerScriptStorage
--HandcuffGuiClone-- local PoliceFolder = game.ReplicatedStorage.Police PoliceFolder.CloneHandcuffGui.OnServerEvent:Connect(function(arrestedplayer) print("Fired") local PersonGettingArresting = arrestedplayer local ClonedGui = game.ServerStorage.Police.GUIs.RequestToHandcuffGui ClonedGui.CuffGui.AreYouSure.Text = "Are you sure you want to arrest".. PersonGettingArresting.."?" end)
I keep getting this error 12:20:37.473 - ServerScriptService.PoliceEvents:8: attempt to concatenate local 'PersonGettingArresting' (a userdata value) I just dont understand whats wrong with the code. I been trying to script this for hours.
You need to change
game.ReplicatedStorage.Police.CloneHandcuffGui:FireServer(tostring(arrestedplayer))
to
game.ReplicatedStorage.Police.CloneHandcuffGui:FireServer(arrestedplayer.Name)
You can't convert a player (userdata) to a string, but you can get their name from player.Name
. Gl on your game, ask if you need any more help! :D