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

How do I locate a player, then what team they are on?

This is my attempt. Obviously doesn't work.

if script.Touched == true then
	if player.child == "humanoid" then
		if player.teams == "Really red" then
			workspace.terminal.brickcolor = BrickColor.new(0,0,1)
		elseif player.teams == "Really black" then
			workspace.terminal.brickcolor = BrickColor.new(1,0,0)
		end
	end
end

I'm trying to find when a player has touch a terminal, it checks if its a humanoid, then depending on what team it changes the block color.

This is just a basic test script. to figure it out.

Help would be extremely welcome!!!

1 answer

✓ Accepted answer

As far as I know, you cannot physically touch a script. You need to define the parent. If you did that, then you also need to define the player.

There are many ways you can do this.

script.Touched:connect(Function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	for _, player in pairs(game:GetService("Players"):GetPlayers()) do
    if player.Team = "Really red"  and humanoid ~= nil then
	workspace.terminal.brickcolor = BrickColor.new(0,0,1)
end
end)

This pretty much says that if the variable "script" is touched, the tag what ever touched it in "hit". then using hit you can search it for the parent which would be where the humanoid is located. Since what would be touching the object would be a part of the character like an arm or a leg.

Then if the humanoid exists do a search for players in the game. if player.Team = "Team name then change the color of the object.

I don't know if this will work since I am fairly new to scripting.

Hope this helps, sorry for grammar I'm lazy lol.

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