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

Handcuff script returning "(a userdata value)" Any Help?

Asked by 6 years ago

LocalScript in Handcuff tool.

1local Officer = game.Players.LocalPlayer
2 
3script.Parent.Handle.Touched:Connect(function(hit)
4    if hit.Parent:FindFirstChild("Humanoid") then
5        local arrestedworkspaceplr = workspace[hit.Parent.Name]
6        local arrestedplayer = game.Players:GetPlayerFromCharacter(arrestedworkspaceplr)
7        game.ReplicatedStorage.Police.CloneHandcuffGui:FireServer(tostring(arrestedplayer))
8    end
9end)

ServerScript in ServerScriptStorage

1--HandcuffGuiClone--
2local PoliceFolder = game.ReplicatedStorage.Police
3 
4PoliceFolder.CloneHandcuffGui.OnServerEvent:Connect(function(arrestedplayer)
5    print("Fired")
6    local PersonGettingArresting = arrestedplayer
7    local ClonedGui = game.ServerStorage.Police.GUIs.RequestToHandcuffGui
8    ClonedGui.CuffGui.AreYouSure.Text = "Are you sure you want to arrest".. PersonGettingArresting.."?"
9end)

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.

1 answer

Log in to vote
1
Answered by 6 years ago

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

0
Players.Sergiomontani10.Backpack.Handcuffs.MainLocal:7: attempt to index local 'arrestedplayer' (a nil value) Sergiomontani10 236 — 6y
0
The problem there doesn't have to do with this question, the problem is arrestedplayer is nil. That means `game.Players:GetPlayerFromCharacter(arrestedworkspaceplr)` doesn't work ArtsicleOfficial 171 — 6y
0
oh Sergiomontani10 236 — 6y
Ad

Answer this question