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

I need help with this syntax error its before "(adminboombox)"?

Asked by 3 years ago
Edited 3 years ago

local MarketPlaceService = game:GetService("MarketplaceService") local players = game:GetService("Players")

local gamePassID = (12940852)

function Spawned(player)

local HasGamepass = false

local success, message = pcall(function()
    HasGamepass = MarketPlaceService:UserOwnsGamePassAsync(player.userid, gamePassID)
end)

if not success then
    warn("Checking in player has gamepass" ..tostring(message))
    return
end

if HasGamepass == true then 
    game.ServerStorage.(AdminBoombox):Clone().Parent = Player.backpack
end

end

if HasGamepass == true then game.ServerStorage.(PompousTheCloud):Clone().Parent = Player.backpack end end

if HasGamepass == true then game.ServerStorage.(BoomBox):Clone().Parent = Player.backpack end end

game.Players.PlayerAdded:Connect(function(player) player.CharterAdded:connect(function() Spawned(player) end) end)

players.PlaySpawned:connect(Spawned)

2 answers

Log in to vote
0
Answered by
rabbi99 714 Moderation Voter
3 years ago
game.ServerStorage.(AdminBoombox)

This won't work ^

Instead try this:

game.ServerStorage["(AdminBoombox)"]

or

game.ServerStorage:WaitForChild("(AdminBoombox)")
Ad
Log in to vote
0
Answered by
TGazza 1336 Moderation Voter
3 years ago

With the above answer its almost correct. Just need to grab the name of the things you're cloning

Assuming this is a cut up function because of the extra end I would change your script from the following:

local HasGamepass = false

local success, message = pcall(function()
    HasGamepass = MarketPlaceService:UserOwnsGamePassAsync(player.userid, gamePassID)
end)

if not success then
    warn("Checking in player has gamepass" ..tostring(message))
    return
end

if HasGamepass == true then 
    game.ServerStorage.(AdminBoombox):Clone().Parent = Player.backpack
end

end

if HasGamepass == true then game.ServerStorage.(PompousTheCloud):Clone().Parent = Player.backpack end end

if HasGamepass == true then game.ServerStorage.(BoomBox):Clone().Parent = Player.backpack end end

game.Players.PlayerAdded:Connect(function(player) player.CharterAdded:connect(function() Spawned(player) end) end)

players.PlaySpawned:connect(Spawned)

To:

local HasGamepass = false

local success, message = pcall(function()
    HasGamepass = MarketPlaceService:UserOwnsGamePassAsync(player.userid, gamePassID)
end)

if not success then
    warn("Checking in player has gamepass" ..tostring(message))
    return
end

if HasGamepass == true then 
    game.ServerStorage[AdminBoombox.Name]:Clone().Parent = Player.backpack
end

end

if HasGamepass == true then game.ServerStorage[PompousTheCloud.Name]:Clone().Parent = Player.backpack end end

if HasGamepass == true then game.ServerStorage[BoomBox.Name]):Clone().Parent = Player.backpack end end

game.Players.PlayerAdded:Connect(function(player) player.CharterAdded:connect(function() Spawned(player) end) end)

players.PlaySpawned:connect(Spawned)

The only way the new code won't work is if your Values AdminBoombox, PompousTheCloud, BoomBox are not objects and are string(names) If that is the case then just change your code to look like this:

-- .... previous code

if HasGamepass == true then 
    game.ServerStorage["AdminBoombox"]:Clone().Parent = Player.backpack
end

end

if HasGamepass == true then game.ServerStorage["PompousTheCloud"]:Clone().Parent = Player.backpack end end

if HasGamepass == true then game.ServerStorage["BoomBox"]:Clone().Parent = Player.backpack end end

game.Players.PlayerAdded:Connect(function(player) player.CharterAdded:connect(function() Spawned(player) end) end)

players.PlaySpawned:connect(Spawned)

of if this is still not the case then try this

-- .... previous code

if HasGamepass == true then 
    game.ServerStorage[AdminBoombox]:Clone().Parent = Player.backpack
end

end

if HasGamepass == true then game.ServerStorage[PompousTheCloud]:Clone().Parent = Player.backpack end end

if HasGamepass == true then game.ServerStorage[BoomBox]:Clone().Parent = Player.backpack end end

game.Players.PlayerAdded:Connect(function(player) player.CharterAdded:connect(function() Spawned(player) end) end)

players.PlaySpawned:connect(Spawned)

hope this helps!

Answer this question