(Bindable)Event Not Firing

  1. What do you want to achieve?
    For an event to fire from a LocalScript to a ServerScript.

  2. What is the issue?
    Doesn’t seem to be firing.

  3. What solutions have you tried so far?
    I tried making an event to fire that particular event but it only seems to be affecting the server as a whole not the client (The client can’t see it but the server does.)

Script:

NewEvent.Event:Connect(function()
	if db then return end
	db = true
	
	local event_index = math.random(#events)

	local event = events[event_index]
	local event_name = event.name
	local event_f = event.f

	print("There is a " .. event_name)
	event_f()
	
	task.wait(3)
	db = false
end)

LocalScript:

function Fixed()
	GeneratorPrompt.Triggered:Connect(function()
		game.Workspace.Spotlight1.Model.LightC.SpotLight.Enabled = true
		game.Workspace.Spotlight1.Model.Model.Light.Material = Enum.Material.Neon
		game.Workspace.Spotlight1.Model.Model.Light.Color = Color3.new(0.776471, 0.776471, 0.427451)

		game.Workspace.Spotlight2.Model.LightC.SpotLight.Enabled = true
		game.Workspace.Spotlight2.Model.Model.Light.Material = Enum.Material.Neon
		game.Workspace.Spotlight2.Model.Model.Light.Color = Color3.new(0.776471, 0.776471, 0.427451)

		game.Workspace["Guard Booth"].Booth.Industrial_Light.ActualLight.PointLight.Enabled = true
		game.Workspace["Guard Booth"].Booth.Industrial_Light.Light.Material = Enum.Material.Neon
		game.Workspace["Guard Booth"].Booth.Industrial_Light.Light.Color = Color3.new(0.776471, 0.776471, 0.427451)
		game.ReplicatedStorage.Sounds.Restored.Playing = true
		NewEvent:Fire()
		print("Fixed!")
	end)
end

local db = true

local tool = script.Parent
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://14210349342"
local track
UIS.InputBegan:Connect(function(input)
	if db == true then
		GeneratorPrompt.PromptButtonHoldBegan:Connect(function()
			db = false
			track = script.Parent.Parent.Humanoid:LoadAnimation(Anim)
			track.Priority = Enum.AnimationPriority.Action
			track.Looped = false
			track:Play()
			if track then
				wait(2.1)
				track:Stop()
				db = true
				if game.Workspace["Guard Booth"].Booth.Industrial_Light.ActualLight.PointLight.Enabled == false then
					Fixed()
				end
			end
		end)
	end
end)

I put a debug after the NewEvent:Fire(), it prints but the event doesn’t seem to execute because nothing happens.

I might just be stupid or I just might’ve missed something.

I am aware the my code is a mess, but I’m optimizing it as I go.

You can’t do this with Bindable Events, it only supports from server or client to itself. Use RemoteEvents instead

2 Likes

As the person above mentioned, you are using the wrong sort of event.


Bindable Events are used for one way communication between scripts, where both scripts are on the server side, or both scripts are on the client side

Bindable Functions are used for two way communication between scripts, where both scripts are on the server side, or both scripts are on the client side.

Remote Events are used for one way communication between the server and the client.

Remote Functions are used for two way communication between the server and the client.


You can read more about remote events and functions here, and more about bindable events and functions here

2 Likes

Google was misleading, told me that it doesnt matter if it’s client to server. But thanks nonetheless!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.