Hi it is giving me a ''attempt to index function with ‘FireServer’ ‘’ error I can’t seem to fix it can someone help here is my code:
local rs = game.ReplicatedStorage
local event = rs.Alim.Branslar:WaitForChild('JGK')
local buton = script.Parent
local function event(plr)
print('Firing evet')
event:FireServer()
print('Event fired')
end
buton.MouseButton1Click:Connect(event)
You have a name collision. You’re using the same name “event” for both the ReplicatedStorage event and your local function. This is causing the error because inside the event function, when you try to call event:FireServer() , you’re actually trying to call the function event itself, which obviously doesn’t have a FireServer method
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage.Alim.Branslar:WaitForChild('JGK')
local button = script.Parent
local function fireEvent(plr)
print('Firing event')
remoteEvent:FireServer()
print('Event fired')
end
button.MouseButton1Click:Connect(fireEvent)