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

if local player = winner then || My script isn't working?

Asked by
N43FGXL 169
4 years ago
local RoundEndV = game.Lighting.Variables.HandleGameVariables.RoundEnd
local Winner = game.Lighting.Variables.ActiveGameVariables.Winner


RoundEndV.Changed:Connect(function()
    if RoundEndV.Value == true then
        if game.Players.LocalPlayer.Character == game.Lighting.Variables.ActiveGameVariables.Winner.Value then
            script.Parent.RoundWin.Visible = true -- Gui for the local player to win
        else
            script.Parent.RoundLose.Visible = true -- Gui for the local player to lose (not the winner)

        end
    end
end)

My script isn't working that is supposed to say "you win" when you are the one who wins the round. If you win the round, which I have a variable for the winner a GUI should say "you win". But It just says "you lose" whenever I complete the objective in my game.

If you need more explanation please ask me!

0
is it a localscript? EmbeddedHorror 299 — 4y
2
also use :GetPropertyChangedSignal("Value") instead of changed EmbeddedHorror 299 — 4y
1
also use :GetPropertyChangedSignal("Value") instead of changed EmbeddedHorror 299 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Here is your problem:

if game.Players.LocalPlayer.Character == game.Lighting.Variables.ActiveGameVariables.Winner.Value then

When seeing if the players name is equal to the string variable just do

if game.Players.LocalPlayer.Name == game.Lighting.Variables.ActiveGameVariables.Winner.Value then

By comparing the character you are only getting a bool value to see if it exist. (True if it is there and False If it isnt) So just call for the players name.

0
When I call for the player's name nothing still occurs... It just gives me the lose gui. N43FGXL 169 — 4y
1
Try using print to see what the variables are. That should help in finding the bug. thoughtless_space 95 — 4y
1
If statements only pass if the condition doesn't equate to false or nil. `if "a" then` will pass, `if 0 then` will pass, `if true then` will pass, but not `if false then`, `if nil then`, nor will `if not true then`. Fifkee 2017 — 4y
0
What happened is my variable wasn't set to the player value in my other script. Thanks for your suggestions! N43FGXL 169 — 4y
0
hmmm N43FGXL 169 — 4y
Ad

Answer this question