The topic says it all. I’m sure that this should work but no. No errors also. Already browsed the forum and went to Googles page 2(I’m desperate).
Here’s my localscript located in players PlayerGui, i created 2 for replicating, both are printing but neither is firing:
LocalScript1:
local RS = game:GetService("ReplicatedStorage")
local RequesteffectEvent = RS:WaitForChild("Requests"):WaitForChild("RequestEffect"):WaitForChild("ProcessRequest")
local container = script.Parent
-- Function to handle button clicks
local function onButtonClick(itemButton)
print("Button clicked:", itemButton.Name) -- 'this' refers to the button that was clicked
-- Add your custom logic here
RequesteffectEvent:FireServer()
end
-- Iterate through existing descendants to find and set up buttons
for _, itemButton in pairs(container:GetDescendants()) do
if itemButton:IsA("TextButton") then
itemButton.MouseButton1Click:Connect(function()
onButtonClick(itemButton)
end)
end
end
container.ChildAdded:Connect(function(itemButton)
if itemButton:IsA("TextButton") then
itemButton.MouseButton1Click:Connect(function()
onButtonClick(itemButton)
end)
end
end)
LocalScript2:
local RequestBtn = script.Parent
local RS = game:GetService("ReplicatedStorage")
local RequesteffectEvent = RS:WaitForChild("Requests"):WaitForChild("RequestEffect"):WaitForChild("ProcessRequest")
RequestBtn.MouseButton1Click:Connect(function()
print("Requesting Effect")
RequesteffectEvent:FireServer()
end)
ServerScript:
local RS = game:GetService("ReplicatedStorage")
local RequesteffectEvent = RS:WaitForChild("Requests"):WaitForChild("RequestEffect"):WaitForChild("ProcessRequest")
local EffectsFolder = RS:WaitForChild("Effects")
RequesteffectEvent.OnServerEvent:Connect(function(player)
print(player.Name)
end)