Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is RemoteEvent Preventing the Rest of my Code from Running Even Before it is Called?

Asked by 6 years ago
Edited 6 years ago

Surprise Surprise. I'm back! And I have a quick message for you all: Merry Christmas!

After my year and a half long hiatus I decided to challenge myself by coding a game in a single week from start to finish. I've almost got the intro GUI all set up but I've come across a problem involving FilteringEnabled and RemoteEvents. I haven't coded on ROBLOX in a year in a half and I know that ROBLOX loves to update to make it impossible for me to really get back into coding like how I used to.


Here's the scenario:

Server Sided(Regular Scripts)

My server script family tree. You can see my serversided code cleverly named, "UI". Inside is a RemoteEvent. Below is my code:

script.RemoteEvent.OnServerEvent:Connect(function(plyr, scripts, val)
    for _,v in pairs(scripts) do
        scripts.Disabled = val
    end
end)

This anonymous function is written perfectly with no errors. The "scripts" argument is a table of scripts that I send though and "val" is a Boolean.

Client Sided(Local Scripts)

I'm just going to post one script as an example. One of my shortest ones so it's easier for people to answer. Below is where my LocalScript is located. And the following is the code:

script.Parent.MouseButton1Click:Connect(function()
    script.Parent:TweenPosition(UDim2.new(.5,0,-.2,0),Enum.EasingDirection.In,Enum.EasingStyle.Back,1,false)
    script.Parent.Style = Enum.ButtonStyle.RobloxRoundButton
    workspace.UI.RemoteEvent:FireServer({script, script.Parent.Parent.Defence.LocalScript.Disabled}, true)
    script.Parent.Parent.Defence:TweenPosition(UDim2.new(.5,0,-.2,0),Enum.EasingDirection.In,Enum.EasingStyle.Back,1,false, function() script.Parent.Parent.OffenceD:TweenPosition(UDim2.new(.25,0,.25,0), Enum.EasingDirection.In, Enum.EasingStyle.Quad,1,false) end)
end)

Since ScriptingHelpers like to squish code together, I'll explain each line by line to make it more understandable.

  • Starts the function with a mouse click event. Lines 1-6 should be no issue.
  • Lines 2 and lines 5 are both tweening. Should be no issue.
  • Line 3 changes the appearance of the button. All aesthetic, no issue should be here.
  • Line 4 is where I fire the server. Again, it is done properly. First a table of scripts and a Boolean for its arguments. Should be no issue.

Now, here's where things start to become interesting. To my knowledge there should be absolutely no issue. All scripts are written cleanly and neatly tabbed for me to read, and on top of that, no errors. Absolutely none in play test and studio mode. The lines before line 4 don't fire either, but they did before I added in FireServer. I have not coded in a while and I am unaware of all the updates ROBLOX has recently done. I'd appreciate any help at all, even if it isn't the exact answer it could help me think of more solutions!



Thanks for everyone willing to help!

-LordDragonZord

0
And I believe this should be kind of a template for newer users of the site. I'm not saying your questions must be as stunningly beautiful as mine, but it should give enough information that the people answering have easier jobs, resulting in you getting more answers. EzraNehemiah_TF2 3552 — 6y
0
I've also already solved the problem by myself. EzraNehemiah_TF2 3552 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
script.Parent.Parent.Defence.LocalScript.Disabled

It looks like you're passing a boolean in that table and it should be your script

script.Parent.Parent.Defence.LocalScript
0
Right, but why is it preventing my previous code from running also? Even before it was called? When I click the script doesn't seem to fire at all. EzraNehemiah_TF2 3552 — 6y
Ad

Answer this question