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

Error with Team based Script?

The goal of this script is to actively change the players script depending on said players team. Here is what I got

function :Changed() --What is the proper function?
plr = script.LocalPlayer
Char = plr.Character
Head = Char.Head
Face = Head.Face
FaceText = Face.Texture
if plr.Team.Name == "Zombies" then
	FaceText = "http://www.roblox.com/asset/?id=179626010"
if plr.Team.Name == "Zombies" then
	FaceText = "http://www.roblox.com/asset/?id=279643280"
else
FaceText = "http://www.roblox.com/asset/?id=64064193"	
end
end
end)

1 answer

You're on the right track with knowing you need to use Changed. Changed is an event, so you can't just use it as a function. I'll explain how to use it, but an explanation of event usage in general can be found here: http://wiki.roblox.com/index.php?title=RBXScriptSignal#Usage

You'll need to take that event and connect it to a function. Since events are members of instances(players, parts, decals, etc) like properties are, you access it with player.Changed. Once you have the event, you need to hook it up to a function for anything to actually happen. You can either set up a named function and give it to the event, or you can define a brand new function as soon as you hook the event up.

Giving it an existing function:

function onChanged()
--do stuff here
end

player.Changed:connect(onChanged)

Creating a function as soon as you connect the event:

player.Changed:connect(function()
--do stuff here
end)

You also have some issues with your function you created. To access the localplayer, it is game.Players.LocalPlayer, and not script.LocalPlayer. You also have an issue with FaceText. You're creating a variable called FaceText and then setting its value to the current texture of the face. This means FaceText is a string variable. If you change FaceText, nothing is going to happen. If you want the face's texture to change, you need to do this:

Face = Head.Face
if plr.Team.Name == "Zombies" then
	Face.Texture = "http://www.roblox.com/asset/?id=179626010"
else
	Face.Texture = "http://www.roblox.com/asset/?id=64064193"  
end

Also, there is no Team property of player. All that exists is TeamColor. You'll have to check if their teamcolor is the same as the zombie team's teamcolor and then do stuff from there.

1 comment

0

Im kinda confused how would incorporate that?

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