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

[UNANSWERED] Not sure what's wrong?

Asked by 8 years ago

Trying to give tools to certain players. Script is in Workspace, tools are in Server Storage. No errors appear or anything, not sure what's wrong.

Allowed = {"Player"}

local MK48 = game.ServerStorage["Mk-48"]
local MK17 = game.ServerStorage["Mk-17"]
local EV = game.ServerStorage["Explosive vest"]

function onPlayerSpawned(p)
for _,v in pairs(Allowed) do
if p.Name:lower() == v:lower() then
MK48:clone().Parent = p.Backpack
MK17:clone().Parent = p.Backpack
EV:clone().Parent = p.Backpack
end
end
end

game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function()
onPlayerSpawned(p)
end)
end)
0
Perhaps use WaitForChild. game.ServerStorage:WaitForChild("Mk-48") funyun 958 — 8y
0
Allowed = {"Player", "Player1"} XToonLinkX123 580 — 8y

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
8 years ago

Are you sure the Player being spawned is named "Player"?

Additionally, you can make this more efficient by using a Dictionary:

Allowed = {Player = true}

local MK48 = game.ServerStorage["Mk-48"]
local MK17 = game.ServerStorage["Mk-17"]
local EV = game.ServerStorage["Explosive vest"]

function onPlayerSpawned(p)
    if Allowed[p.Name] then
        MK48:Clone().Parent = p.Backpack
        MK17:Clone().Parent = p.Backpack
        EV:Clone().Parent = p.Backpack
    end
end

game.Players.PlayerAdded:connect(function(p)
    p.CharacterAdded:connect(function()
        onPlayerSpawned(p)
    end)
end)
0
It doesn't work, I'm really clueless at this point. Arceus3317 10 — 8y
0
Must be something wrong on your end then. unmiss 337 — 8y
Ad

Answer this question