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

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

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?

3 comments

0

I will take a look through the settings, but I still have no idea.

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?

0

Is ScriptsDisabled true in ScriptContext?

1 answer

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.

1 comment

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.

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