Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I am trying to make a Live Event that gives every player in the game a sword. How could I do this?

Here is what I have tried:

local timeToStart = 1591052400

local timeToStop = 1591052450

function liveEvent()
	local Sword = game.ReplicatedStorage.Sword
	sword.Parent = game.Players.LocalPlayer.Backpack
	
end

while wait(1) do
	local timeNow = os.time()
	
	if timeNow >= timeToStop then
		break
	end
	if timeNow >= timeToStart then
		print "Start the Live Event"
		liveEvent()
		break
	else
		print("Time till live event: "..(timeToStart-timeNow).." seconds")
	end
end

The Live Event script works fine, but the problem is that it needs to be in a Server Script and i can not use LocalPlayer in a Server Script. How could I give the Sword to all of the players? Thanks!

1 answer

for i,v in pairs(game.Players:GetChildren()) do
     local Sword = game.ReplicatedStorage.Sword:Clone()
     Sword.Parent = v.Backpack
end

This finds every player and gives them the sword 1 at a time as fast as possible

This discussion is preserved as it was. New answers, comments, and votes are closed.