What do you want to achieve?
I would like to change a player’s team after touching an object and reset their player
What is the issue?
incompetence
What solutions have you tried so far?
Well, since I don’t know how to use lua yet, I’ve tried looking at the resources online and typing my own code but to no avail.
my code:
local function onTouched(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.Team = "red";
end
end```
local function onTouched(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
game.Players:GetPlayerFromCharacter(humanoid.Parent).Team = game.Teams.Red
end
end
game.Workspace.Part.Touched:Connect(onTouched)
Is it a Server Script or Local Script?
Also, did you change game.Workspace.Part to your desired part?
local function onTouched(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
game.Players:GetPlayerFromCharacter(humanoid.Parent).Team = game.Teams.Red
end
end
game.Workspace.Part.Touched:Connect(onTouched) -- Here, change game.Workspace.Part to your desired part