Okay so I've made this gui (Using a complicated video tutorial that didn't totally work) But the buying stuff works, but when you buy the weapon (As an example a sword) it won't attack, what to do? Here is the script for the weapon and other stuff:
The sword item buying thingy script:
script.Parent.MouseButton1Click:connect(function()
local RS = game:GetService("ReplicatedStorage")
local item = RS:WaitForChild("Sword")
local price = 99 -- Change Your Price Here
local player = game.Players.LocalPlayer
local stats = player:WaitForChild("leaderstats")
if stats.Money.Value >= price then -- Change the Money to your Currency Name
stats.Money.Value = stats.Money.Value - price
local cloned = item:Clone()
local cloned2 = item:Clone()
cloned.Parent = player.Backpack
cloned2.Parent = player.StarterGear
end
end)
Leaderboard:
game.Players.ChildAdded:connect(function(player)
local stats = Instance.new("Model",player)
stats.Name="leaderstats"
local money = Instance.new("IntValue",stats)
money.Name="Money"
money.Value=300 -- Change Your Starting Money
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
local tag = character.Humanoid:FindFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
local stats = tag.Value:WaitForChild("leaderstats")
stats["Money"].Value = stats ["Money"].Value + 5
end
end
end)
end)
end)
I also put the weapon item in ReplicatedStorage. Thanks - keketin

3 comments
Wow!
Please post the script for the sword, because if it isn't attacking, then the problem is probably in the sword, not in theses lines of code
I've told you the problem over Discord (Just so people are not thinking "Why isn't he answering". xd)