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 5 years ago

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.

1 answer

Log in to vote
1
Answered by 5 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 — 5y
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 — 5y
0
oh Sergiomontani10 236 — 5y
Ad

Answer this question