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

Why is this script not firing my bindable event?

Alright so how this works is when a model's PowerValue is true which i have set-up correctly, it is suppose to fire this bindable event with the code inside. I have this exact same set-up but without tweening involved. Why is this not firing? The script that's not working.

Power = script.Parent.Power
ArenaLightsEvent = game.ReplicatedStorage.LightingEvents:WaitForChild("TronArenaLighting")
TweenArenaLightsEvent = game.ReplicatedStorage.LightingEvents:WaitForChild("TweenTronArenaLighting")
--Made By MillerrIAm
--Helpers Liliardio & WeArefSociety
--------------------------------------------------------------------
--Start Script
Power.Changed:Connect(function(Value)
	if Value then
		while Power.Value do
			TweenArenaLightsEvent:Fire("White")
			wait(0.5)
			TweenArenaLightsEvent:Fire("Black")
			wait(0.5) -- WaitTime, I'd recommend Changing this to like 10 seconds if it's not a moving tron.
		end
	end
end)

Here's my Light Tweening Script.

--Made By MillerrIAm--
---------------Variables---------------
ReplicatedStorage = game.ReplicatedStorage
tweenArenaLights = game.ReplicatedStorage.LightingEvents.TweenTronArenaLighting
local children = game.Workspace.ArenaLights:GetChildren()
local TweenLight = require(game.ServerScriptService["ModuleScripts|Lighting"].LightTweenModule)
---------------Main Code---------------
tweenArenaLights.Event:Connect(function(player,light)
---------------Colors---------------
if light == "Blue" then
	for i, v in pairs(children) do
		if v:FindFirstChild("PointLight") ~= nil then
			TweenLight.Tween(v.PointLight,Color3.fromRGB(0,0,255),nil)
		end
	end
wait(0.01)
elseif light == "Red" then
	for i, v in pairs(children) do
        if v:FindFirstChild("PointLight") ~= nil then
			TweenLight.Tween(v.PointLight,Color3.fromRGB(255,0,0),nil)
        end
      end
wait(0.01)
elseif light == "Green" then
	for i, v in pairs(children) do
		if v:FindFirstChild("PointLight") ~= nil then
			TweenLight.Tween(v.PointLight,Color3.fromRGB(0,255,0),nil)
		end
	end
wait(0.01)
elseif light == "Yellow" then
	for i, v in pairs(children) do
        if v:FindFirstChild("PointLight") ~= nil then
			TweenLight.Tween(v.PointLight,Color3.fromRGB(255,255,0),nil)
        end
      end
wait(0.01)
elseif light == "Orange" then
	for i, v in pairs(children) do
		if v:FindFirstChild("PointLight") ~= nil then
			TweenLight.Tween(v.PointLight,Color3.fromRGB(255,85,0),nil)
		end
	end
wait(0.01)
elseif light == "Cyan" then
	for i, v in pairs(children) do
		if v:FindFirstChild("PointLight") ~= nil then
			TweenLight.Tween(v.PointLight,Color3.fromRGB(0,255,255),nil)
		end
	end
wait(0.01)
elseif light == "Purple" then
	for i, v in pairs(children) do
		if v:FindFirstChild("PointLight") ~= nil then
			TweenLight.Tween(v.PointLight,Color3.fromRGB(255,0,255),nil)
		end
	end
wait(0.01)
elseif light == "Pink" then
	for i, v in pairs(children) do
		if v:FindFirstChild("PointLight") ~= nil then
			TweenLight.Tween(v.PointLight,Color3.fromRGB(255,0,127),nil)
		end
	end
wait(0.01)
---------------Black & White---------------
elseif light == "BrightWhite" then
	for i, v in pairs(children) do
		if v:FindFirstChild("PointLight") ~= nil then
			TweenLight.Tween(v.PointLight,Color3.fromRGB(255,255,255),nil)
        end
      end
      wait(0.01)
elseif light == "White" then
      for i, v in pairs(children) do
        if v:FindFirstChild("PointLight") ~= nil then
			TweenLight.Tween(v.PointLight,Color3.fromRGB(255,255,255),nil)
        end
      end
      wait(0.01)
elseif light == "Blackout" then
      for i, v in pairs(children) do
        if v:FindFirstChild("PointLight") ~= nil then
			TweenLight.Tween(v.PointLight,Color3.fromRGB(0,0,0),nil)
        end
      end
      wait(0.01)
	elseif light == "Black" then
      for i, v in pairs(children) do
        if v:FindFirstChild("PointLight") ~= nil then
			TweenLight.Tween(v.PointLight,Color3.fromRGB(0,0,0),nil)
        end
      end
      wait(0.01)
    end
end)

Thank you for help in advance!

1 answer

✓ Accepted answer

Unlike RemoteEvents and RemoteFunctions, BindableEvents do not return the player who called the function under the first argument.

When you are calling BindableEvent:Fire(), the event in this case is interpreting the argument "player" as the string argument you passed, causing the light argument to appear nil.

To fix this, simply remove the argument "player" from the arguments list. If you still need it for some reason, you have to make sure you're passing the player as the first argument as again, it will not do it for you.

1 comment

0

How did I miss that? Wow, thank you man.

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