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.
2 comments
Where is the script located? Also that 'do' is pretty useless. It just makes the code more complicated.
The 'wait(4)' is also useless, since it's at the end of a function/coroutine. The problem is likely that the first ActivateFish changes something important so that running it a second time doesn't work. If you printed out every time onWelcomePlayerFired, I expect you'd find that the function is running every time the event is fired.