Hi There, been having issues with changing Bool Values from Server to Client, I already tried to make a Event.
Here’s the deal: Whenever a LocalPlayer chooses a Character from the GUI, it will fire a Event from Client to Server.
After it, another Remote Event is fired from Server to Client indicating that they can now access all GUIs.
First Client Side Code
CharacterFrame.Choose.MouseButton1Click:Connect(function()
if CharacterFrame.Choose.X.Text == "Selected" then
return
end
local AdditionalButton = script.Parent.Parent.AdditionalButtons
game.ReplicatedStorage.DiamondsEvent:FireServer(character.Name)
script.Parent.Visible = false
AdditionalButton.Visible = false
for i, characterfr in pairs(script.Parent.Characters:GetChildren()) do
if characterfr:IsA("ViewportFrame") then
characterfr.Choose.X.Text = "Select"
end
end
CharacterFrame.Choose.X.Text = "Selected"
end)
Server Side Code
game.ReplicatedStorage:WaitForChild("DiamondsEvent").OnServerEvent:Connect(function(player, chosenCharacter)
RSG.CharacterClientEvent:FireClient(player, false)
... -- This is all that it needs from the Server Side to be seen, the rest are Detecting to Morph to a Character
It works up until this part, but when its firing back to a different script, it doesn’t work. Though it doesn’t give back any Errors.
Client side Code
function DetectMorphValue(toggle)
if toggle == false then
SCBool.Value = false
else
SCBool.Value = true
end
end
CharacterClientEvent.OnClientEvent:Connect(DetectMorphValue)
This is how my Explorer in StarterGui and ServerScriptService Looks like
That didn’t work too, I tried to change DetectMorphValue to DetectMorphValue(player, toggle) but since its a client event, shouldn’t it need to call player since its local?
no error on my end, but the Bool Value is still set to true even if I have morphed already.
I just replicated what you’re doing and it worked perfectly fine. Are you sure the function is running? Is there any possibility you’re firing back with an event the client cannot see?
hold on, so there’s nothing suppose to be wrong with it? well whenever I morph into a character, I respawn but stay on the same area where I’m standing.
pls don’t tell me that it worked but whenever I respawn it resets back to true- because if it does, this post would be just so dumb
Is there any possibility you’re firing back with an event the client cannot see?
Nope, I’m pretty sure I’m using FireClient to send back to the Client’s side
That’s… probably the issue. If your value is ‘true’ by default and is placed in a place where it will be reset every time your character does… yeah. You can consider having a value on the server for each player joined instead.
is there anyway I can just do a while loop on the startergui? it seems more complicated that way for me but I’ll try and see if its a better solution to what I’m making
ooo so your telling me, that I should just make a value for every player in the server, and have it changed server side if the player changed to another character.
and possibly have my local script in local player side to listen to that so whenever it checks if the value is changed, it can enable what I want to do?