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

Why won't my generator turn on? (I am new to FE scripting.)

Asked by 6 years ago

I have no idea if there is anything wrong with this, because I am not getting any errors. It is not working though. Please someone help me.

wait(0.5)
local cd = game.Workspace.GeneratorOne:WaitForChild("On"):WaitForChild("ClickDetector")
local s = cd.Parent.Parent.server
cd.MouseClick:connect(function()
    print("C") -- Attempt to see if this part was running, wasn't.
    if s.Value == false then
        print("b") -- Attempt to see if this part was running, wasn't.
        game.Workspace.GenUp:FireServer()
        s.Value = true
    else
        end
end)

https://gyazo.com/a9a23736fda0505c7c05f8108a586a4c

0
Is this a server script or local? User#19524 175 — 6y
0
For events, :connect is actually deprecated and isn't recommended, try changing it to :Connect instead. YabaDabaD0O 505 — 6y
0
@YabaDadaD0O using `:connect()` won't make the script not work. oreoollie 649 — 6y
0
Make sure to accept the answer if it helped you. Zafirua 1348 — 6y

1 answer

Log in to vote
1
Answered by
Zafirua 1348 Badge of Merit Moderation Voter
6 years ago
Edited 6 years ago

It seems you have not understood the definition of Remote Events.

What are Remote Events?

Remote Events are a Roblox Instance which allows the Server Script to communicate with a Local Script. Not Server Script to Server Script or Local Script to Local Script.

In your scenario, you attempted on communicating Server Script with another Server Script. I am stating this because that is what you showed in your GIF. The call is never invoked. Thus, it does not error, nor does any of it print.

So. What is the Solution?

What are Bindable Events?.

Bindable Events are also Roblox Instances with its function similar to of Remote Events except, it only communicates with the same type i.e Server Script to Server Script and Local Script to Local Script.

Now I cannot exactly use your code but take a look at my example.

Server Script 1

-- [Declaration Section]
local Baseplate         = workspace.Baseplate;
local Click             = Baseplate.ClickDetector;
local BindableEvent     = workspace.Event;
local Zafs_Str          = "Brrrrrr";

-- [Processing Section]
local function On_Click ()
    BindableEvent:Fire(Zafs_Str);
end;

-- [Connecting Section]
Click.MouseClick:Connect(On_Click);

Server Script 2

-- [Declaration Section]
local BindableEvent     = workspace.Event;

-- [Processing Section]
local function Print_When_Invoked (str)
    print(str);
end;

-- [Connecting Section]
BindableEvent.Event:Connect(Print_When_Invoked);

Resources to Learn.

0
Thank you. I will read up on them more. keegaroo65 11 — 6y
Ad

Answer this question