Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Calling player from a character?

I have a script that teleports a victim when it is touched by handcuffs and also changes a bool value. The bool value is a child of the player and I can't figure out how to call the player

script.Parent.CuffEvent.OnServerEvent:Connect(function(player, victim)
	victim.CFrame = game.Workspace.Prison.prisonpart.CFrame
	local victimplayer = victim.Name
	game:GetService("Players").victimplayer:WaitForChild("IsArrested").Value = true
end)

any help?

1 answer

You can use the Players:GetPlayerFromCharacter function to get the player from their character.

script.Parent.CuffEvent.OnServerEvent:Connect(function(player, victim)
    victim.CFrame = game.Workspace.Prison.prisonpart.CFrame
    local victimplayer = game:GetService("Players"):GetPlayerFromCharacter(victim)
    victimplayer:WaitForChild("IsArrested").Value = true
end)

1 comment

0

The parameter is the model object of the player's character, so make sure that is being passed on.

This discussion is preserved as it was. New answers, comments, and votes are closed.