Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago
Edited 7 years ago

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

0
you could just put "skullsword" in starterpack abnotaddable 920 — 7y
0
i need it to wait 5 secs then it gives the item i am making a knife game.. CapRocksCR -3 — 7y

1 answer

Log in to vote
2
Answered by 7 years ago

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!

Ad

Answer this question