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

Script doesn't work to update a string value?

So I have a string value ("Role") in StarterCharacterScripts that is parented to another string value ("Plr") -- (not sure if this is related to the problem)

The script I'm trying is in StarterPlayerScripts. I want it to change the value of "Role" but it doesn't work and I'm wondering what I'm doing wrong:

while true do
wait (.0001)
if script.Parent.Parent.TeamColor == BrickColor.new("White") then
script.Parent.Parent.Character.Plr.Role.Value = "Medic"
end
end

2 comments

0

is there an error?

0

nope, no errors in output

1 answer

✓ Accepted answer

Try:

local player = game.Players.LocalPlayer

repeat wait() until player.Character

while true do
	wait (.0001)
	if player.TeamColor == BrickColor.new("White") then
		player.Character.Plr.Role.Value = "Medic"
	end
end

Make sure it's a localscript

2 comments

0

I was about to write an answer, but you beat me! (As a brief explanation, you have to wait for the Character to load in or it will return as nil)

0

This worked, thank you!

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