I am making a script where if you click on a UI button then the bool value will change. Since you can’t change the bool value client sided I did it so that if the button was clicked (detecting with a local script) it will make the server script enabled which would change the value. The problem is the local script is not enabling the server script.
Code:
– Server
while task.wait() do
if script.Enabled == true then
game.StarterGui.MenuScreen.PlayPressed.Value = true
end
end
I dont think you can enable Server Scripts via LocalScript, Server Scripts only fire for the Server while LocalScripts fire for the Client, try using a RemoteEvent
I dont know what is Cairo trying to do but that code is wrong, your Code also makes no sense to me.
Create a RemoteEvent and put it in ReplicatedStorage.
Client:
local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
script.Parent.MouseButton1Click:Connect(function()
print("Clicked")
remoteEvent:FireServer()
end)
Server:
local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
remoteEvent.OnServerEvent:Connect(function(player)
game.StarterGui.MenuScreen.PlayPressed.Value = true
end)
You can change the BoolValue via Client but it will just be Visible for you. Changing the BoolValue from the Server, like we do in the Script i gave u will change it for all Players in the Game. You cant change a Server owned Instance from the Client, it would change just for you, not for others, that also means you cant enable a Server Script from the Client.
You wrote game.StarterGui.MenuScreen.PlayPressed.Value = true, that will do nothing, the StarterGui will copy its Instances to the PlayerGui, the StarterGui does just exist in your Studio(Not sure but its not existing for the Player itself).
You are using a ServerScript to change a Value what is inside the Client on a MenuScreen, you dont need to use Server if you just want to make it Visible for you, if you want to use Server then there are other better ways.
When the player joins there is a cutscene menu, when the play button is pressed it will make the PlayPressed value true and then the cutscene will end. I only want everything to be for the client so the value would change only for the person who pressed play
Then you just need this to make the Value change for you:
Client:
local playPressed = "Where your Value located at, Example: script.Parent.Parent:WaitForChild("PlayPressed")"
script.Parent.MouseButton1Click:Connect(function()
print("Clicked")
playPressed.Value = true
end)