The LocalScript is in a GUI Button. It reads the value of a stat (in this case "BuzzleStage") and then alters the button. If the value is zero, the image disappears and the other script remains disabled. If the value is one, it changes the image of the button and should enable the script.
As far as changing the image on the button, it actually works. I've had no issues with that part. However, I can't get the localscript to un-disable the other script. (The other script has to be a normal script to work btw.) I'm sure this is probably due to the limits of what a LocalScript is allowed to do, so is there a workaround for this or a way to fix it?
Thanks in advance! Here is the localscript in block code.
local player = game.Players.LocalPlayer local stats = player:WaitForChild("leaderstats") local BuzzStats = stats["BuzzleStage"] local tl = script.Parent BuzzStats.Changed:Connect(function() if BuzzStats.Value == 0 then tl.Image = "rbxassetid://0" tl.Buzzle.Disabled = true else if BuzzStats.Value == 1 then tl.Image = "rbxassetid://6556591249" tl.Buzzle.Disabled = false end end end)
Simple answer: You can't.
Any changes made by LocalScripts will not be read by the server. This includes trying to enable scripts from the client. For actions that have to be done, such as this action, you will have to use a normal Script, otherwise you'll be stuck at a dead end.
That being said, client-server communication can be accomplished using RemoteEvents
and/or RemoteFunctions
. These instances allow a script to communicate with a script "on the other side of the wall". (For reference, BindableEvents
and BindableFunctions
do not have this "wall", and behave much like how you'd socialize with other people.) Imagine the wall has a door that can only be opened with a key. That key is the signal sent by the event or function to allow the script on the other side to perform instructions based on the signal.
For RemoteEvents
, FireServer(args)
will send a signal to an awaiting script on the server, passing the player who fired the signal as well as a tuple of arguments args
, if given. FireClient(player, args)
sends a signal to the client player
with a tuple of arguments args
, if given. FireAllClients(args)
sends a signal to every client connected to the server and passes a tuple of arguments args
, if given.
Since you are doing this from the client, FireServer()
should be used, and the script waiting for the signal should be a normal Script that will enable the desired script(s).
everything is right except elseif is wrote like this elseif and not else if xdddd