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

How do I load character a player that was touched by a part?

Asked by 5 years ago

--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)

1 answer

Log in to vote
0
Answered by
Echtic 128
5 years ago
Edited 5 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

Try getting the player like this, the function does exactly what it says, gets the player from the character.

local character = h.Parent
local player = game.Players:GetPlayerFromCharacter(character)
0
Nevermind, Fixed this. LightningLIon58 49 — 5y
Ad

Answer this question