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

Why is my script displaying the lose screen instead of the win (Changed)?

Asked by
N43FGXL 169
4 years ago

PickV is the person who is picked/holding the object.

local RoundEndV = game.Lighting.Variables.HandleGameVariables.RoundEnd
local PickV = game.Lighting.Variables.ActiveGameVariables.Pick
local localPlayerN = game.Players.LocalPlayer.Name

RoundEndV.Changed:Connect(function()
    if RoundEndV.Value == true then
        print(localPlayerN) -- For Testing
        print(PickV.Value) -- For Testing

        if localPlayerN == PickV then
            script.Parent.RoundWin.Visible = true
            print("Round Win")
        elseif localPlayerN ~= PickV then
            script.Parent.RoundLose.Visible = true
            print("Round Lose")
        end
    end
end)

I'm not sure why my script is showing the lose screen instead of the win screen. When I do my tests the two prints are the same value... I hope you can help me, I have posted this before but my problem is slightly different.

0
The script is a local script in a gui. N43FGXL 169 — 4y
0
What kind of data do the Values hold? The name? The player object itself? If they're not the same type, they'll never be equal. Jahaziel_VanDerHas 238 — 4y
0
My script is saying if the player's name is the same as the winner's then the gui will say "you won". N43FGXL 169 — 4y
0
The values hold string values. One is the player's name and the other is a string value. Do I need to use a different kind of variable? N43FGXL 169 — 4y
View all comments (2 more)
0
If the values hold strings too, make sure they don't have extra spaces or anything, then. Print their length. Something is fishy here if they actually show you the "same" value but actually aren't. Jahaziel_VanDerHas 238 — 4y
0
move the variables into replicated storage. Replicated storage was created for a reason EmbeddedHorror 299 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

u have to use .Value for values. example:

local RoundEndV = game.Lighting.Variables.HandleGameVariables.RoundEnd
local PickV = game.Lighting.Variables.ActiveGameVariables.Pick.Value--changed to value.
local localPlayerN = game.Players.LocalPlayer.Name

RoundEndV.Changed:Connect(function()
    if RoundEndV.Value == true then
        print(localPlayerN) -- For Testing
        print(PickV) -- For Testing

        if localPlayerN == PickV then
            script.Parent.RoundWin.Visible = true
            print("Round Win")
        elseif localPlayerN ~= PickV then
            script.Parent.RoundLose.Visible = true
            print("Round Lose")
        end
    end
end)
0
omg thank you so much! I didn't realize that tiny error! N43FGXL 169 — 4y
0
np EmbeddedHorror 299 — 4y
Ad

Answer this question