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

How to make a script give something, an item or money only once in first time join only?

For example, a starter sword that I only want to be given out on first join (as it will be saved by data store) so it will not duplicate on next joins.

--current give code--
function onJoin()
	local start = game.Lighting.StarterSword:Clone()
	start.Parent = player.Inventory
end

Do I need to create a bool value that in the player that will save on the datastore to indicate if a tool has been given already or not? or is there a simpler way?

1 answer

###When a player leaves, its descendants and character will be removed as well. No need to worry about that. Also, don't use Lighting to store things. The only objects that should go there are skyboxes and post effects. I don't think a sword is a skybox or post effect.

--current give code--
function onJoin(player)
    local start = game:GetService("ServerStorage").StarterSword:Clone()
    start.Parent = player.Backpack
    start:Clone().Parent = player.StarterGear
end

game:GetService("Players").PlayerAdded:Connect(onJoin)

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