For i, v in pairs(game.Players:GetPlayers()) do only alerts one player in the server

My problem is that basically it only alerts one person and not everyone in the server. Heres the code:

script.Parent.blu.Event:Connect(function()
	local real = game.ServerStorage.spooky:Clone()
	for i, v in pairs(game.Players:GetPlayers()) do
		real.Parent = v.PlayerGui
		game:GetService("TweenService"):Create(real.ImageLabel,TweenInfo.new(1,Enum.EasingStyle.Linear),{ImageTransparency = 1}):Play()
	end
end)
1 Like

You only clone it once and add it to the last player. You need to move the clone line inside the for loop.
local real = game.ServerStorage.spooky:Clone()

1 Like

I did that because i wanted to destroy it earlier but i was afraid if i put task.wait(tweentime) it would just wait 1 second and then move on to another player

You can use the Debris service to delay destroying things without yielding the code

script.Parent.blu.Event:Connect(function()
	for _, player in game.Players:GetPlayers() do
		local real = game.ServerStorage.spooky:Clone()
		real.Parent = player.PlayerGui
		game:GetService("TweenService")
			:Create(real.ImageLabel, TweenInfo.new(1, Enum.EasingStyle.Linear), { ImageTransparency = 1 })
			:Play()
		game:GetService("Debris"):AddItem(real, 1)
	end
end)

thanks i was suffering with this problem

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.