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

I have a boolean value in StarterGui. More Bio. Help?

game.ReplicatedStorage.ModeEvents.TynReleaseEvent.OnServerEvent:Connect(function(plr)
	if plr.PlayerGui.ModeActive == false then
	local eff = game.ReplicatedStorage.ModeEffects.TynReleaseEffect:Clone()
	local char = plr.Character.Torso
	eff.Parent = char
	plr.PlayerGui.ModeActive = true
	else
		print("Mode Already Active")
		end
end)

The boolean value is going to change from true to false, depending whether or not the player has a mode active, but it keeps saying the ModeActive isn't in PlayerGui, but when I run the game, I can visibly see it in PlayerGui. Help!

1 answer

✓ Accepted answer

You cannot access PlayerGui from the server. You should change anything on ClientSide from your LocalScript that fires the server. Also, you should get the value when firing the server so the server can read your BoolValue. Also, you should set .Value of the object to false not set the object to false, along with checking the value. Although this may not be the best solution due to exploiters, you should probably have something ServerSide like a ClickDetector or something for them to click instead of whatever you're using.

ServerScript:

game.ReplicatedStorage.ModeEvents.TynReleaseEvent.OnServerEvent:Connect(function(plr, sentBool)
    if sentBool == false then
	if plr.Character:WaitForChild('Torso'):FindFirstChild('TynReleaseEffect') then return print('Player already has effect in Torso.') end --Stops the script if they already have the effect, prevents some exploiters.
   	local eff = game.ReplicatedStorage.ModeEffects.TynReleaseEffect:Clone()
    	local char = plr.Character.Torso
    	eff.Parent = char
    else
        print("Mode Already Active")
     end
end)

LocalScript:


game.ReplicatedStorage.ModeEvents.TynReleaseEvent:FireServer(game.Players.LocalPlayer.PlayerGui.ModeActive.Value)
game.Players.LocalPlayer.PlayerGui.ModeActive.Value = true

Let me know in the comments if you have any issues or questions.

1 comment

0

Thanks for catching the fact I was setting the object to false, oof. They click on a GUI button, and it changes their mode. Any suggestions to prevent exploiters from overlapping modes?

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