I have a script that when the parent (button) is touched and the player has more than 5 Quarcks (the playstats currency name) then it takes away 5 Quarcks and gives the player an extra 10 MaxHealth for only one life, the brick turns black for a second before returning to red. The script is as follows:
local brick = script.Parent
local maxheal = 10
local price = 5
local player = game.Players.LocalPlayer
local stats = player:WaitForChild("leaderstats")
local function onPartTouch(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if stats.Quarcks.Value == price then
stats.Quarcks.Value = stats.Quarcks.Value - price
if humanoid then
local currentHealth = humanoid.MaxHealth
local newHealth = currentHealth + maxheal
humanoid.Health = newHealth
brick.BrickColor = BrickColor.new("Black")
wait(1)
brick.BrickColor= BrickColor.new("Really Red")
end
end
brick.Touched:Connect(onPartTouch)
I'm not sure what is going wrong as when I try to touch the brick, nothing happens. The model is as follows: Model> Humanoid, Head - Head> Script.

1 comment
This worked, thank you. I found out I mucked a bit of my script a bit and put some lines in the wrong place