–Script inserted in handcuffs handle
tm = script.Parent
local RemoteEvent = game.ReplicatedStorage.ChangeTeam1
function onTouched(hit)
local h = hit.Parent:FindFirstChild(“Humanoid”)
if h ~= nil then
local n = hit.Parent
local player = game.Players:FindFirstChild(""…n.Name…"")
if player.Team ~= game.Teams.Police then
local PrisonersColor = “Deep orange”
RemoteEvent:FireServer(BrickColor.new(PrisonersColor))
else
–does nothing
end
end
end
script.Parent.Touched:connect(onTouched)
–script in serverscriptservice
game.ReplicatedStorage.ChangeTeam1.OnServerEvent:Connect(function(player, teamColor)
if player.Team ~= game.Teams.Police then
player.TeamColor = teamColor
player:LoadCharacter()
end
end)
Try getting the player like this, the function does exactly what it says, gets the player from the character.
1 | local character = h.Parent |
2 | local player = game.Players:GetPlayerFromCharacter(character) |