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

Nuke Sytem is not working correctly. How and what is wrong?

So I am working on a Nuclear System and it does not work. It does use a RemoteEvent. When the RemoteEvent activates, it causes a bool value to become True and after a wait(), another one becomes true. This however does not work.

RemoteEvent is located in ReplicatedStorage and is called NukeSystem. Here are the scripts.

ClickDetector:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local NukeSystem = ReplicatedStorage:WaitForChild("NukeSystem")
local Notification = ReplicatedStorage:WaitForChild("Notification")

function onClicked()
	NukeSystem:FireAllClients("bam")
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

ServerScriptService RemoteEvent Handler:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local NukeSystem = ReplicatedStorage:WaitForChild("NukeSystem")

NukeSystem.OnServerEvent:connect(function(bam)
	workspace.NukeFacility.Nuke.NukeEnabled.Value = true
	wait(79.30)
	workspace.NukeFacility.Nuke.Landed.Value = true
end)

Can you please explain why it does not work when I click on the part. Thank You!

17 comments

0

Any errors?

0

Nope

0

try in the clickdetector replacing "bam" with just bam

0

ok

0

That has not wirked. bam also beame underlined in blue

0

show me the new script

0

local ReplicatedStorage = game:GetService("ReplicatedStorage") local NukeSystem = ReplicatedStorage:WaitForChild("NukeSystem") local Notification = ReplicatedStorage:WaitForChild("Notification") function onClicked() NukeSystem:FireAllClients(bam) Notification:FireAllClients("NUKE", "A Nuke was launched! Avoid Downtown!") end script.Parent.ClickDetector.MouseClick:connect(onClicked)

0

Are you using a local script for the click detector? It seems like you are using a local script to fire a event for all clients from the client it self. iirc, FireAllClients is for server script only.

0

Both are a Script. Not Local scripts. Should I chagnge them where should the Serverscriptservice script go?

0

Ahhhh... If im right, you are using a server script to detect a server event. Change the service script in server script service into a local script.

0

Should I change where the location of the new local scrpt is?

0

Yes, put it into the starter player scripts

0

Does not work. Error: OnServerEvent can only be used on the server. Located in Line4

0

Oh my bad, change that to OnClientEvent instead. Since you are already using a server script to fire all clients, you use that to let the client receive the event

0

It is Semi Broken. Its Value is enabled to my client but not to the server. I need it to be Enabled on both. How would I do this?

0

Do you want to have a local script and a server script or both server scripts? Since this will change the Remote event being used.

0

I would love to have both honestly. Just a bit confusing on how.

2 answers

This should work Using a BindableEvent, both Server Script Using Bindable Event to communicate with between Server Scripts. See here

Click Detector

local CD = script.Parent.ClickDetector
local RP = game:GetService("ReplicatedStorage")
local NukeSystem = RP:WaitForChild("NukeSystem")

function OnClicked()
	NukeSystem:Fire()
end

script.Parent.ClickDetector.MouseClick:connect(OnClicked)

Event Handler

local RP = game:GetService("ReplicatedStorage")
local NukeSystem = RP:WaitForChild("NukeSystem")

local NukeEnabled = workspace.NukeFacility.Nuke.NukeEnabled
local Landend = workspace.NukeFacility.Nuke.Landed

function OnEvent()
	NukeEnabled.Value = true
	wait(79.30)
	Landend.Value = true
end

NukeSystem.Event:Connect(OnEvent())

If this helps, remember to accept! Thanks! Report errors here

3 comments

0

Does not work. Fire is not a valid member of RemoteEvent Line 6

0

Can u explain error from answer from Xviper Error is : Fire is not a valid member of RemoteEvent

0

Im using a Bindable event, not a remote event

Not really an answer, but knowing about exploiters myself, they can trigger Remote's, so if your nuke is going to be triggered via RemoteEvent, they can make a "script" and inject it into your game and spam it.

2 comments

0

It is fine as I have scripts that I use for these issues.

0

Can u explain error from answer from Xviper Error is : Fire is not a valid member of RemoteEvent

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