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

Problem with my script?

Asked by 10 years ago

It's not working, may someone help me fix it?

01local gear = Game.Lighting.flag
02 
03local GamePassId = 163409880  -- This is the right gamepass id
04 
05Game.Players.PlayerAdded:connect(function(Player)
06Player.CharacterAdded:connect(function()
07    if Player.StarterGear.flag ~= true then
08        local gearClone = gear:clone()
09        gearClone.Parent = Player.StarterGear
10        wait(0.1)
11        local gearClone2 = gear:clone()
12        gearClone2.Parent = Player.Backpack
13 
14        print("Success")
15 
16end
17end)
18end)

1 answer

Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
01local gear = game.Lighting.flag --Lua is case sensitive, it's game not Game.
02 
03local GamePassId = 163409880  -- This is the right gamepass id
04 
05game.Players.PlayerAdded:connect(function(Player) --Lua is case sensitive, it's game not Game.
06Player.CharacterAdded:connect(function()
07if game:GetService("MarketplaceService"):PlayerOwnsAsset(Player ,GamePassId) then --You wanted the script to be a VIP script right?
08  local gearClone = gear:clone()
09        gearClone.Parent = Player.Backpack --StarterGear is not a member of Player, Backpack is though.
10        wait(0.1)
11        local gearClone2 = gear:clone() --Why give them two?
12        gearClone2.Parent = Player.Backpack
13 
14        print("Success")
15end
16end)
17end)

The script will only work in online mode, if you experience errors there, then press F9 and tell us the output (red part with some blue lines explaining the problem).


I don't see why a admin has noted this answer, I did give explanation why the code was not working as intended, and that was because Starterpack is not in Player.

0
Edited, you shouldn't need that line to tell if you have the flag in your inventory or not, since you respawned with a new set of tools. M39a9am3R 3210 — 10y
0
Thank you very much! KillSide 0 — 10y
Ad

Answer this question