New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

[SOLVED]How do you give a player a tool from a script?

Asked by
sydre 63
8 months ago
Edited 8 months ago

I've made the following script to give the player a mic whenever he joins, however it doesn't work. If I change the script to put the mic in the workspace it will do that but not in the player's Backpack

--// DataStore

local DataStore = game:GetService("DataStoreService")

local Cash = DataStore:GetDataStore("CashData")

local Mic = DataStore:GetDataStore("MicData")

local Song = DataStore:GetDataStore("SongsData")

--// Main function

game.Players.PlayerAdded:Connect(function(Player)

pcall(function()

local LB = Instance.new("Folder", Player)

LB.Name = "DataStats"

local C = Instance.new("IntValue", LB)

C.Name = "Cash"

C.Value = Cash:GetAsync(Player.UserId)

local Mics = Mic:GetAsync(Player.UserId)

local Songs = Song:GetAsync(Player.UserId)

-- // Creating the mics datastore if there isn't any

if Mics == nil then

Mics = {["Using"] = "Starter mic", ["Starter mic"] = true}

end

if Mics["Starter mic"] == nil then

Mics["Starter mic"] = true

end

local MicCopy = game.ReplicatedStorage.Mics:FindFirstChild(Mics["Using"]):Clone() MicCopy.Parent = Player.Backpack -- This is the part I'm having trouble with
Mic:SetAsync(Player.UserId, Mics)

--// Creating the songs datastore if there isn't any

if Songs == nil then

Songs = {["Easy Listening"] = 1, ["Glam Metal"] = 0, ["Grunge"] = 0, ["Reggae "] = 0, ["Blues Rock"] = 0, ["New Age"] = 0, ["Arena Rock"] = 0, ["Swing"] = 0, ["Folk"] = 0, ["Dance Pop"] = 0, ["Adult Contemporary"] = 0, ["Hip Hop"] = 0, ["Synthpop"] = 0, ["New Wave"] = 0, ["Jazz"] = 0, ["Dance"] = 0, ["Alternative Rock"] = 0, ["Progressive Rock"] = 0, ["Heavy Metal"] = 0, ["Pop Rock"] = 0, ["Disco"] = 0, ["Latin"] = 0, ["Country Pop"] = 0, ["Soul"] = 0, ["Rock and Roll"] = 0, ["Country"] = 0, ["Rhythm and Blues"] = 0, ["Hard Rock"] = 0, ["Rock"] = 0, ["Pop"] = 0}

end

Song:SetAsync(Player.UserId, Songs)

--// AutoSave

C.Changed:Connect(function()

Cash:SetAsync(Player.UserId, C.Value)

end)

end)

end)

0
ew non code blocks user LoganboyInCO 150 — 8mo

Answer this question