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

Why is the player spawning on default spawn? [Unsolved]

Asked by 9 years ago

The script is supposed to make the player's team change when the value called "mech" changes. Unfortunately, the player is staying neutral, and is spawning at default spawn! Why is that happening? here is the script

while true do
    wait(0.1)
    if script.Parent.Parent.MechValue.Value == 1 then
        script.Parent.Parent.Parent.Parent.Neutral =  false
        script.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Institutional white")
        print("Picked white")
    elseif script.Parent.Parent.MechValue.Value == 2 then
        script.Parent.Parent.Parent.Parent.Neutral =  false
        script.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Medium stone gray")
        print("Picked gray")
    elseif script.Parent.Parent.MechValue.Value == 3 then
        script.Parent.Parent.Parent.Parent.Neutral =  false
        script.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Really black")
        print("Picked black")
    end
end

Please help!!! Thank you!!! OUTPUT:Players.Player.PlayerGui.ScreenGui.TextButton.Script:17: 'end' expected (to close 'while' at line 1) near '<eof>'

1
Does the script print something and what's its location? TheMyrco 375 — 9y
1
Also, I suggest using elseifs. TheMyrco 375 — 9y
0
its location is inside a screenGUI, inside a textbutton yogipanda123 120 — 9y

1 answer

Log in to vote
2
Answered by
Sublimus 992 Moderation Voter
9 years ago

[EDIT: Fixed if error] First, let's clean up your code with a little tabbing. Next, use elseifs instead of multiple if statements. Lastly, players have a Neutral value that defaults to True, so you must set it to False to allow players to change teams.

Code that reflects changes:

while true do
    wait(0.1)
    if script.Parent.Parent.MechValue.Value == 1 then
        script.Parent.Parent.Parent.Parent.Neutral =  false
        script.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Institutional white")
        print("Picked white")
    elseif script.Parent.Parent.MechValue.Value == 2 then
        script.Parent.Parent.Parent.Parent.Neutral =  false
        script.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Medium stone gray")
        print("Picked gray")
    elseif script.Parent.Parent.MechValue.Value == 3 then
        script.Parent.Parent.Parent.Parent.Neutral =  false
        script.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Really black")
        print("Picked black")
    end
end

Also, next time, if this is all the code in the script, I suggest using game.Players.LocalPlayer within a LocalScript instead to reduce the amount of parents.

1
Ah, had completely forgotten the Neutral option. Hope this helps the OP. TheMyrco 375 — 9y
0
It didn't help, it makes sense, and the neutral part is definitely important but it didn't work! yogipanda123 120 — 9y
1
Are the parent's correctly oriented and is it printing anything? Sublimus 992 — 9y
1
I fixed the script, I forgot to change an if, let me know if it works now Sublimus 992 — 9y
View all comments (6 more)
0
ok, it is changing the teams now, but still going to nuetral spawn yogipanda123 120 — 9y
1
Do the SpawnLocations have the right TeamColor properties as well? TheMyrco 375 — 9y
0
Yes I think so, the block color is right, and then TeamColor is the same color (I.E Institutional white) yogipanda123 120 — 9y
1
Peculiar case then. Are you testing it online? Sometimes it bugs (or at least used to bug) in other modes. TheMyrco 375 — 9y
0
doesn't work for either, although thanks for telling me because apparently my camera script doesn't work! yogipanda123 120 — 9y
0
Spawn locations also have a Neutral Value! Make sure it is false! Sublimus 992 — 9y
Ad

Answer this question