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

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

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!

3 comments

0

is it a localscript?

2

also use :GetPropertyChangedSignal("Value") instead of changed

1

also use :GetPropertyChangedSignal("Value") instead of changed

1 answer

✓ Accepted answer

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.

5 comments

0

When I call for the player's name nothing still occurs... It just gives me the lose gui.

1

Try using print to see what the variables are. That should help in finding the bug.

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.

0

What happened is my variable wasn't set to the player value in my other script. Thanks for your suggestions!

0

hmmm

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