local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
user = game.Players:findFirstChild(human.Parent.Name)
script.Parent.ShopGUI:clone().Parent = player.PlayerGui
wait(2)
else
wait(2)
debounce = false
end
end
script.Parent.Touched:connect(onTouch)
That's the present script.
The main:
-- StrangeEnd
player = script.Parent.Parent.Parent.Parent.Parent
money = player.leaderstats.Cash -- Change Gold to the money you want to be used to buy the item
price = 100 -- Your price goes here
tool = game.Lighting:findFirstChild("Flare")
function buy()
if money.Value >= price then
money.Value = money.Value - price
local a = tool:clone()
a.Parent = player.Backpack
local b = tool:clone()
b.Parent = player.StarterGear
end
end
script.Parent.MouseButton1Down:connect(buy)
I can't even find the problem. Because when I tes it in play it won't work. :\ |