Why is this not working?

Hey developers,

So I have an issue. I’m trying to fire an event from the client but it won’t work.

image

I tried it on a part and got the same error:

script.Parent.ClickDetector.MouseClick:Connect(function()
	game.ReplicatedStorage.NukeEvent:FireServer()
end)

Someone please help!

:heart: Thank you!

3 Likes

You’re firing a RemoteEvent instance from a regular script. As the error states, FireServer() can only be called on the Client.

Instead, I’d recommend using :FireClient(), and have a LocalScript in StarterPlayerScripts about what to do when the RemoteEvent is fired.

RemoteEvent:FireClient(args)
1 Like

Okay so in StarterPlayerScripts what should I do?

Since you’re firing a RemoteEvent from the server I’m assuming that you have a Script in ServerScriptService that handles what happens when the event is fired. Simply change that from the server to the client, and that should resolve the issue!

I don’t, I just have it in a script in the workspace.

Since you’re only firing the RemoteEvent; it won’t do anything. In StarterPlayerScripts, you can add a LocalScript that detects when the event is fired, and what happens.

For example, here’s a showcase of what you can do:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent") -- // Change the name of this to the name of your remote event

local function onClientReceive()
   -- // This prints out "Remote Event Fired!" once connected to the firing request.
   print("Remote event fired!")
end

RemoteEvent.OnClientEvent:Connect(onClientReceive)

1 Like

So I need to fire an event that sets off a nuke in the workspace, so would I just send out another event or what?

EDIT: By the way this is the nuke script:

wait(1)

script.Parent.Missle.Base.Anchored = true

debounce = false

game.ReplicatedStorage.NukeEvent.OnServerEvent:Connect(function()
	if debounce == false then
		debounce = true
		
		local siren = script.Parent.Siren
		siren.Parent = workspace
		siren:Play()
		
		coroutine.resume(coroutine.create(function()
			local lights = script.Parent.Lights:GetChildren()
			for i=1,100 do
				for i,v in pairs(lights) do
					v.SpotLight.Enabled = true
				end
				wait(1)
				for i,v in pairs(lights) do
					v.SpotLight.Enabled = false
				end
				wait(1)			
			end
		end))
		
		wait(2)
		
		script.Parent.Missle.Base.Fire.Enabled = true
		script.Parent.Missle.Base.Smoke.Enabled = true
		
		wait(3)
		
		script.Parent.Missle.PrimaryPart = script.Parent.Missle.Base	
		for i=1,320 do
			script.Parent.Missle:SetPrimaryPartCFrame(script.Parent.Missle:GetPrimaryPartCFrame()+Vector3.new(0,0.05*((1.1^(i/5))/3),0))
			wait()
		end
		wait()
		for i=1,100 do
			script.Parent.Missle:SetPrimaryPartCFrame(script.Parent.Missle:GetPrimaryPartCFrame()+Vector3.new(0,0.05*(1.1^((250-i)/5)/3),0))
				script.Parent.Missle:SetPrimaryPartCFrame(script.Parent.Missle:GetPrimaryPartCFrame()*CFrame.Angles(0,math.pi/100,0))
				script.Parent.Missle:SetPrimaryPartCFrame(script.Parent.Missle:GetPrimaryPartCFrame()+Vector3.new(0,0,-i/100))	
			wait()
		end
		wait()
		for i=200,120,-1 do
			script.Parent.Missle:SetPrimaryPartCFrame(script.Parent.Missle:GetPrimaryPartCFrame()-Vector3.new(0,0.1*((1.1^(i/2.95))/4),0))
			wait()
		end	
		
		script.Parent.Missle.Tip.Transparency = 0.5
		script.Parent.Missle.Tip.CanCollide = false
		script.Parent.Missle.Tip.Mesh.Scale = Vector3.new(1,1,1)
		local boom = script.Parent.Boom
		boom.Parent = workspace
		boom:Play()
		local frame = script.Parent.Missle.Tip.CFrame
		
		script.Parent.Missle.Tip.Boom.Disabled = false	
		
		for i=1,400 do
			script.Parent.Missle.Tip.Size=script.Parent.Missle.Tip.Size+Vector3.new(3,3,3)
			script.Parent.Missle.Tip.CFrame=frame
			wait()
		end
		script.Parent.Missle.Tip.Boom.Disabled=true
		script.Parent.Missle:Destroy()
		siren:Stop()
		boom:Stop()
		
		
	end
end)

Is the event supposed to be for one player or multiple players?

Multiple, it’s ment to destroy the whole server when it gets activated (like break every single model/part)

In that case, from your Script in the workspace, you can use the :FireAllClients() event. This will replicate your Nuke script to every connected client.

Additionally, you’ll need to switch the .OnServerEvent() script (the one you linked above) to a .OnClientEvent() in StarterPlayerScripts instead, like what I showed earlier in this thread

So I should do this:

(Client RemoteEvent Script)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage.NukeEvent -- // Change the name of this to the name of your remote event

local function onClientReceive()
	print("Nuke Event")
end

RemoteEvent.OnClientEvent:Connect(onClientReceive)

(Part Script)

script.Parent.ClickDetector.MouseClick:Connect(function()
	game.ReplicatedStorage.NukeEvent:FireAllClients()
end)

Yes, if you do that, it should print “Nuke Event” in the console!

Okay great it worked, but now the nuke isn’t doing what it should. How can I make it so the nuke script activates?

Paste the nuke script into the new LocalScript.

1 Like

Nothing is printing anymore, the nuke isn’t working and I don’t think the script is working either.

This is the code inside of the LocalScript.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage.NukeEvent -- // Change the name of this to the name of your remote event

local function onClientReceive()
	wait(1)

	warn("The nuke has been launched!")
	game.Workspace.Nuke.Missle.Base.Anchored = true

	local debounce = false
		if debounce == false then
			debounce = true

			local siren = game.Workspace.Nuke.Siren
			siren.Parent = workspace
			siren:Play()

			coroutine.resume(coroutine.create(function()
				local lights = game.Workspace.Nuke.Lights:GetChildren()
				for i=1,100 do
					for i,v in pairs(lights) do
						v.SpotLight.Enabled = true
					end
					wait(1)
					for i,v in pairs(lights) do
						v.SpotLight.Enabled = false
					end
					wait(1)			
				end
			end))

			wait(2)

			game.Workspace.Nuke.Missle.Base.Fire.Enabled = true
			game.Workspace.Nuke.Missle.Base.Smoke.Enabled = true

			wait(3)

			game.Workspace.Nuke.Missle.PrimaryPart = game.Workspace.Nuke.Missle.Base	
			for i=1,320 do
				game.Workspace.Nuke.Missle:SetPrimaryPartCFrame(game.Workspace.Nuke.Missle:GetPrimaryPartCFrame()+Vector3.new(0,0.05*((1.1^(i/5))/3),0))
				wait()
			end
			wait()
			for i=1,100 do
				game.Workspace.Nuke.Missle:SetPrimaryPartCFrame(game.Workspace.Nuke.Missle:GetPrimaryPartCFrame()+Vector3.new(0,0.05*(1.1^((250-i)/5)/3),0))
				game.Workspace.Nuke.Missle:SetPrimaryPartCFrame(game.Workspace.Nuke.Missle:GetPrimaryPartCFrame()*CFrame.Angles(0,math.pi/100,0))
				game.Workspace.Nuke.Missle:SetPrimaryPartCFrame(game.Workspace.Nuke.Missle:GetPrimaryPartCFrame()+Vector3.new(0,0,-i/100))	
				wait()
			end
			wait()
			for i=200,120,-1 do
				game.Workspace.Nuke.Missle:SetPrimaryPartCFrame(game.Workspace.Nuke.Missle:GetPrimaryPartCFrame()-Vector3.new(0,0.1*((1.1^(i/2.95))/4),0))
				wait()
			end	

			game.Workspace.Nuke.Missle.Tip.Transparency = 0.5
			game.Workspace.Nuke.Missle.Tip.CanCollide = false
			game.Workspace.Nuke.Missle.Tip.Mesh.Scale = Vector3.new(1,1,1)
			local boom = game.Workspace.Nuke.Boom
			boom.Parent = workspace
			boom:Play()
			local frame = game.Workspace.Nuke.Missle.Tip.CFrame

			game.Workspace.Nuke.Missle.Tip.Boom.Disabled = false	

			for i=1,400 do
				game.Workspace.Nuke.Missle.Tip.Size=game.Workspace.Nuke.Missle.Tip.Size+Vector3.new(3,3,3)
				game.Workspace.Nuke.Missle.Tip.CFrame=frame
				wait()
			end
			game.Workspace.Nuke.Missle.Tip.Boom.Disabled=true
			game.Workspace.Nuke.Missle:Destroy()
			siren:Stop()
			boom:Stop()


		end
	end)
end

RemoteEvent.OnClientEvent:Connect(onClientReceive)

@Schedency

bump

Can anyone else help? I need help with this

Hello, can anyone help me? I really need some assistance here. @Schedency?

Hello, I do not think you should bump your help and feedback this frequently, typically people will come around at some point, that is not a rule, it is just a note.

But lets see where Schedency left you off.
To confirm.
You have:

  • A local script that doesn’t work when the server calls it
  • A server script that fires all clients to work the nuke

And to confirm:

  • Your NukeEvent is still in ReplicatedStorage not in any file, folder or other.
  • There are no errors
  • You are firing all clients and have tested that you fire all clients

Am I correct with everything so far?

1 Like

Hi DreamyDev! I’m back even shinier and with a bigger golden aspect.

Anyways what the current issue did anything get fixed. Just update me on the current situation.

Yes. That is completely correct.

image