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

I have a problem where the script won't even run, any ideas?

Asked by 9 years ago

Okay, so I have a program that gives a gun to a player, if they have the game pass, but now, it won't even run, without an error code. Here is the code, but that probably won't help, as it use to work just fine, and I made sure it wasn't disabled.

local passId = 168101268

gun = game.Lighting.Turret
print ('started to give a gun')
function isAuthenticated(player) 
    return game:GetService("GamePassService"):PlayerHasPass(player, passId)
end

game.Players.PlayerAdded:connect(function(plr)
    if isAuthenticated(plr) then
    print 'giving gun'
        local newgun = gun:clone()
newgun.Parent = plr.Backpack
newgun.Parent = plr.StarterGear
print 'gun givin'
    end
end)

it's weird, becuase it worked just fine yesterday, but today, it just stopped working today. Does anyone have any ideas?

0
I will take a look through the settings, but I still have no idea. rollercoaster57 65 — 9y
0
Infact, none of the server scripts are working, my data stores are not working, my gamepass awarding is not working, is roblox down right now? or what? rollercoaster57 65 — 9y
0
Is ScriptsDisabled true in ScriptContext? gskw 1046 — 9y

1 answer

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

You change it's parent twice. Since the last thing you changed it to was StarterGear, that's where the gun will be.

It's also possible that the script runs before the gun exists. Fix this by doing

gun = game.Lighting:WaitForChild("Turret")

Make sure you do not test this is PlaySolo, because PlayerAdded events don't fire in PlaySolo. On top of that, you won't own the pass in PlaySolo.

0
No, I fixed it, there was no error code, but this is happening now because the game is getting so big on lines of code and instances, So all the server scripts have to disabled, then re-enabled. I also can't play my game in solo mode anymore because my computer cannot handle running a client and server at once, on this game only. That is how big it is now. rollercoaster57 65 — 9y
Ad

Answer this question