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

How Can I Give My Friends A Dearkheart Using A Script Like This?

Asked by
jacobwow 140
10 years ago

I am trying to make a script that gives a dearkheart to my friends when they join my game, it appears though that this one did not work. Can anyone fix it or make a better one?

local VIP = { ["FluffyCatToast"] = true, ["CRhockey48"] = true } 
local Tool = Game:GetService("ServerStorage"):WaitForChild("Darkheart")

Game:GetService("Players").PlayerAdded:connect(function(plr)
    if VIP[plr.Name:lower()] == true then
        Tool:Clone().Parent = plr.Backpack
        Tool:Clone().Parent = plr.StarterGear
    end
end)

1 answer

Log in to vote
0
Answered by 10 years ago

Try this: (I use it in my game.)

game.Players.PlayerAdded:connect(function(p)
    if p.Name == "FluffyCatToast" then
        local Tool = game.ServerStorage.Darkheart:Clone()
        Tool.Parent = p.StarterGear --if it's on playeradded they will have it anyways.
    end
end)

game.Players.PlayerAdded:connect(function(p)
    if p.Name == "CRhockey48" then
        local Tool = game.ServerStorage.Darkheart:Clone()
        Tool.Parent = p.StarterGear --if it's on playeradded they will have it anyways.
    end
end)

I know it's inefficient to use multiple PlayerAdded events, but it works fine.

Ad

Answer this question