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

When I Click My Money Goes Away But I Don't Get The Item?

So Far I Have Made A Script And All I Need Is For It To Give Me The Item :/:

local debounce = false
function getPlayer(humanoid) 
local players = game.Players:children()
local user = game.Players.LocalPlayer
local player = game.Players.LocalPlayer
for i = 1, #players do 
if players[i].Character.Humanoid == humanoid then return players[i] end 
end 
return nil 
end 

script.Parent.MouseButton1Click:connect(function()

local gold = game.Players.LocalPlayer.leaderstats.Cash -- Replace MONEY with the name of currency name your leaderboard uses

if gold.Value >= 100 then -- Replace 100 with your price    

	gold.Value = gold.Value - 100 -- Replace 100 with your price

	local m = Instance.new("Message")

	m.Text = "You just bought a Laser Gun!" -- Replace TOOL with your weapon
	

	m.Parent = game.Players.LocalPlayer.PlayerGui
	wait(3)
	m:Destroy()

wait(1)
local Gear1 = script.Parent.LaserGun
Gear1:Clone() 
Gear1:Clone()
Gear1:Clone()
Gear1:Clone()
Gear1:Clone()
Gear1:Clone() 
Gear1:Clone()
Gear1:Clone()
Gear1:Clone()
Gear1:Clone()
Gear1:Clone() 
Gear1:Clone()
Gear1:Clone()
Gear1:Clone()
Gear1:Clone()
Gear1.Parent = game.Players.LocalPlayer

	wait(2)

	m.Parent = nil

else

	m = Instance.new("Message")

	m.Text = "You don't have enough for that!"
	m:Destroy()

	m.Parent = game.Players.LocalPlayer.PlayerGui

	wait(3)

	m.Parent = nil

end



wait(2)

debounce = false
	
end)











Please Help

1 comment

0

Is This A Local Script? If so, what is it under?

2 answers

✓ Accepted answer

Put the laser gun that you want to clone inside of ReplicatedStorage.

So when you go to clone it do

local player = game.Players.LocalPlayer

local laserGun = game.ReplicatedStorage.NameOfYourGunGoesHere -- insert name of your tool
laserGun.Parent = player.Backpack

this only works if it is a local script btw

2 comments

0

Thank You

0

no problem!

Gear1:Clone()
Gear1.Parent = game.StarterPack

When you say "game.Players.LocalPlayer" you're not putting it in your inventory/backpack.

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