Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

4 comments

0

Is this a server script or local?

0

For events, :connect is actually deprecated and isn't recommended, try changing it to :Connect instead.

0

@YabaDadaD0O using :connect() won't make the script not work.

0

Make sure to accept the answer if it helped you.

1 answer

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.

1 comment

0

Thank you. I will read up on them more.

This discussion is preserved as it was. New answers, comments, and votes are closed.