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?

local gear = Game.Lighting.flag 

local GamePassId = 163409880  -- This is the right gamepass id 

Game.Players.PlayerAdded:connect(function(Player) 
Player.CharacterAdded:connect(function() 
    if Player.StarterGear.flag ~= true then
        local gearClone = gear:clone()
        gearClone.Parent = Player.StarterGear
        wait(0.1)
        local gearClone2 = gear:clone()
        gearClone2.Parent = Player.Backpack

        print("Success")

end
end)
end)

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.
local gear = game.Lighting.flag --Lua is case sensitive, it's game not Game.

local GamePassId = 163409880  -- This is the right gamepass id 

game.Players.PlayerAdded:connect(function(Player) --Lua is case sensitive, it's game not Game.
Player.CharacterAdded:connect(function() 
if game:GetService("MarketplaceService"):PlayerOwnsAsset(Player ,GamePassId) then --You wanted the script to be a VIP script right?
  local gearClone = gear:clone()
        gearClone.Parent = Player.Backpack --StarterGear is not a member of Player, Backpack is though.
        wait(0.1)
        local gearClone2 = gear:clone() --Why give them two?
        gearClone2.Parent = Player.Backpack

        print("Success")
end
end)
end)

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