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

Why Isnt It Working? Its A Item Giver That Waits 5 Secs And Gives You An Item

Hello , I Need Help With My Code!

game.Players.PlayerAdded:connect(function(player)
        player.CharacterAdded:wait()
        if wait(5) then
            game.Lighting:FindFirstChild("SkullSword"):Clone().Parent = player.Backpack
        end
    end)

Its Not Working Please Help Me. Thank You! Btw I Am New To LUA

2 comments

0

you could just put "skullsword" in starterpack

0

i need it to wait 5 secs then it gives the item i am making a knife game..

1 answer

✓ Accepted answer

First, make sure this is a Server Script inside of ServerScriptService.

Now let me re-write your code;

game.Players.PlayerAdded:Connect(function(p) -- use connect with a cap C
	p.CharacterAdded:Wait()
	wait(5)
	local CT = game.Lighting:WaitForChild("SkullSword"):Clone() -- we use waitforchild to wait untill it loads in
	CT.Parent = p.Backpack
end)

Try this code. It may or may not solve your problem. I don't see any other problems here. Here's a few stuff you can do if it still doesn't work;

  1. Make sure you got the name of the sword correct
  2. Add variables for the sword
  3. change the location of "SkullSword" to ReplicatedStorage
  4. re - write your code

I'm sure one of these should help.

Good luck and have fun developing!

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