Need to locate event!

Since you found a solution, mark your last post as the solution so that this topic shows the checkmark.

1 Like

Still not what i wanted though it enables other ppls lightsabers too

1 Like
Char.ChildAdded:Connect(function(ItemAdded)
      If ItemAdded:IsA(“Tool”) then
      Local lightsaber = char:FindFirstChild(“lightsaber”)
      —your code for the lightsaber
      end
end)
1 Like

sadly this didnt work either
my code (Edited):

local plr = game.Players.LocalPlayer
local char = plr.Character
char.ChildAdded:Connect(function(ItemAdded)
	if ItemAdded:IsA("Tool") then
	local lightsaber = char:FindFirstChild("lightsaber")
		local remoteEvent =	lightsaber:FindFirstChild("Enable/Disable").EnableSaber
		function onclick()
			remoteEvent:FireServer()
			script.Parent.Parent.Parent.Visible = false
			script.Parent.Parent.Parent.Parent.WhenEnabled.Visible = true
			script.Parent.Ignite:Play()
		end
end
end)

script.Parent.MouseButton1Click:connect(onclick)

Ourput says:
Players.ThenewdevonRoblox.Backpack.Lightsaber.MobileGui.MobileGui.WhenDisabled.Enable.Enable.LocalScript:3: attempt to index nil with ‘ChildAdded’

1 Like

Try this:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
char.ChildAdded:Connect(function(ItemAdded)
	if ItemAdded:IsA("Tool") then
	local lightsaber = char:FindFirstChild("lightsaber")
		local remoteEvent =	lightsaber:FindFirstChild("Enable/Disable").EnableSaber
		function onclick()
			remoteEvent:FireServer()
			script.Parent.Parent.Parent.Visible = false
			script.Parent.Parent.Parent.Parent.WhenEnabled.Visible = true
			script.Parent.Ignite:Play()
		end
end
end)

script.Parent.MouseButton1Click:connect(onclick)
1 Like

Believe the issue was the way you referenced the character, tool, etc
This script should work

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait() --if character hasnt loaded yet, wait

local function onclick()
	local Lightsaber = Char:FindFirstChild("Lightsaber") --im assuming this is the tool
	if Lightsaber then
		local EnableFolder = LightSaber:FindFirstChild("Enable/Disable") --assuming this is a folder
		local EnableEvent = EnableFolder:FindFirstChild("EnableSaber")

		EnableEvent:FireServer()
		script.Parent.Parent.Parent.Visible = false
		script.Parent.Parent.Parent.Parent.WhenEnabled.Visible = true
		script.Parent.Ignite:Play()
	end
end

script.Parent.MouseButton1Click:connect(onclick)
2 Likes

TY this is just what i needed!

1 Like

Is this in the tool or the screenGUI?

1 Like

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