works perfectly only the first time it happens, what's the problem?
local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local player = Players.LocalPlayer local welcomePlayerEvent = ReplicatedStorage:WaitForChild("FishEvent") local playerGui = player:WaitForChild("PlayerGui") local function onWelcomePlayerFired() do local henlo = script.Parent.ActivateFish:Clone() henlo.Parent = script.Parent henlo.Name = "Clone" henlo.Disabled = false wait(4) end end welcomePlayerEvent.OnClientEvent:Connect(onWelcomePlayerFired)
First let's get your variables down
local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local player = Players.LocalPlayer local welcomePlayerEvent = ReplicatedStorage:WaitForChild("FishEvent") local playerGui = player:WaitForChild("PlayerGui")
The do on line 10 is pretty much useless so let's get rid of it, also lets combine the function and calling it.
welcomePlayerEvent.OnClientEvent:connect(function() end)
Next i'm going to add your code in with just a bit of rearranging(idk i like it in a order ;p)
welcomePlayerEvent.OnClientEvent:connect(function() local henlo = script.Parent.ActivateFish:Clone() henlo.Name = "Clone" henlo.Parent = script.Parent henlo.Disabled = false end)
No point in adding the wait(4) because the event can be called over and over
Let's put it together
local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local player = Players.LocalPlayer local welcomePlayerEvent = ReplicatedStorage:WaitForChild("FishEvent") local playerGui = player:WaitForChild("PlayerGui") welcomePlayerEvent.OnClientEvent:connect(function() local henlo = script.Parent.ActivateFish:Clone() henlo.Name = "Clone" henlo.Parent = script.Parent henlo.Disabled = false end)
As long as no other script is deleting that ActivateFish instance you should be fine.