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

Why does this script no work?

Asked by 10 years ago

Happy Near Years Eve everyone. Anyway, so this value (with the script in it) is placed into your character from a different script (That works). The script that is not working is supposed to change the value of the StringValue to something specific, which depends on which team you are on. However, the script doesn't work. I have no idea why, and Output gave me nothing. Can someone please help me? Here's the script:

local check = game.Players:getPlayerFromCharacter(script.Parent.Parent)

repeat 
wait()
until check:findFirstChild("TeamColor")

while true do

if check.TeamColor == ("Bright violet") then
wait(0.1)
script.Parent.Value = "AL"
elseif check.TeamColor == ("Bright yellow") then
wait(0.1)
script.Parent.Value = "Brazil"  
elseif check.TeamColor == ("Bright blue") then
wait(0.1)
script.Parent.Value = "China"
elseif check.TeamColor == ("White") then
wait(0.1)
script.Parent.Value = "EU"  
elseif check.TeamColor == ("Bright orange") then
wait(0.1)
script.Parent.Value = "India"   
elseif check.TeamColor == ("Brown") then
wait(0.1)
script.Parent.Value = "NorthKorea"  
elseif check.TeamColor == ("Bright red") then
wait(0.1)
script.Parent.Value = "Russia"  
elseif check.TeamColor == ("Bright green") then
wait(0.1)
script.Parent.Value = "US"  
end 
end 

1 answer

Log in to vote
0
Answered by
nilVector 812 Moderation Voter
10 years ago

This is an easily fixable but common mistake.

You're trying to compare a Color3value with a String value.

You cannot do:

if check.TeamColor == ("Bright violet") then

Instead, it has to be:

if check.TeamColor == BrickColor.new("Bright violet") then
0
It still won't work, except Output actually gave me something this time. Output gave me this: "Players.Player.PlayerGui.Insert.Allegiance.Checker:5: attempt to index local 'check' (a nil value)" CoolJohnnyboy 121 — 10y
0
It could possibly be that you said "check = game.Players:getPlayerFromCharacter" when the 'g' in "getPlayerFromCharacter" should be capitalized...so like this: check = game.Players:GetPlayerFromCharacter(script.Parent.Parent) nilVector 812 — 10y
0
If that doesn't work, give me some more information - Is this in a local script? Whose player from character are you trying to get? nilVector 812 — 10y
Ad

Answer this question