hello guys i am currently making mobile buttons for my swordfighting game but, i can’t locate the event inside the tool of the player character…
the gui is located in the “PlayerGui”
i have tried locating it with this script before but it didnt work…
the event is located in the tool when the tool is held
local plr = game.Players.LocalPlayer
local char = plr.Character
local remoteEvent = char.FindFirstChild("Lightsaber")["Enable/Disable"].EnableSaber -- doesnt locate the event in the players tool
function onclick()
remoteEvent:FireServer()
script.Parent.Parent.Parent.Visible = false
script.Parent.Parent.Parent.Parent.WhenEnabled.Visible = true
script.Parent.Ignite:Play()
end
script.Parent.MouseButton1Click:connect(onclick)
It’s because you’re trying to find the lightsaber before it’s even in the players hand, you should check every time the player pulls the lightsaber out
local tool = --put the tool here
tool.Equipped:Connect(function()
local plr = game.Players.LocalPlayer
local char = plr.Character
local remoteEvent = char.FindFirstChild("Lightsaber")["Enable/Disable"].EnableSaber -- doesnt locate the event in the players tool
function onclick()
script.Parent.Parent.Parent.Visible = false
script.Parent.Parent.Parent.Parent.WhenEnabled.Visible = true
script.Parent.Ignite:Play()
end
script.Parent.MouseButton1Click:connect(onclick)
end)
local bc i want it to play on the client and replicate it on the server with the remoteEvent:FireServer()
wich i need to locate but i cant locate it sadly
this sadly doesnt work and yes i do know how to script only i need to locate 1 event in a tool from the playergui not “StarterGui” and the gui is only in the playergui when a mobile player is holding the tool
local tool = script.Parent
tool.Equipped:Connect(function()
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local remoteEvent = tool: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
script.Parent.MouseButton1Click:connect(onclick)