So, I just made a spinner and some code so every time you touch the spinner it changes the text to 1 less life and lowers your health by 10, and to prevent regeneration, I just made it set it to the number but -10 instead of subtracting 10 from the health. Anyway, my script does not work because it does not lower the lives and also lowers your health too fast. I tried to fix the last problem by making it wait but it still doesn't work. However I did figure out I need to add a debounce but how do I do that? Im new at lua so please try to keep it simple, help on this would be appreciated. This is my script:
--Variables--
local Brick = script.Parent
local LivesA = workspace.spinner.Lives.BillboardGui.TextLabel.Text
local SpinningSpeed = workspace.spinner.PlatformBase.HingeConstraint.AngularVelocity
--End--
--Code--
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
if LivesA == "Lives: 10" then
LivesA = "Lives: 9"
Parent.Humanoid.Health = 90
end
end
end
Brick.Touched:connect(PlayerTouched)
wait(1)
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
if LivesA == "Lives: 9" then
LivesA = "Lives: 8"
Parent.Humanoid.Health = 80
end
end
end
Brick.Touched:connect(PlayerTouched)
wait(1)
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
if LivesA == "Lives: 8" then
LivesA = "Lives: 7"
Parent.Humanoid.Health = 70
end
end
end
Brick.Touched:connect(PlayerTouched)
wait(1)
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
if LivesA == "Lives: 7" then
LivesA = "Lives: 6"
Parent.Humanoid.Health = 60
end
end
end
Brick.Touched:connect(PlayerTouched)
wait(1)
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
if LivesA == "Lives: 6" then
LivesA = "Lives: 5"
Parent.Humanoid.Health = 50
end
end
end
Brick.Touched:connect(PlayerTouched)
wait(1)
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
if LivesA == "Lives: 5" then
LivesA = "Lives: 4"
Parent.Humanoid.Health = 40
end
end
end
Brick.Touched:connect(PlayerTouched)
wait(1)
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
if LivesA == "Lives: 4" then
LivesA = "Lives: 3"
Parent.Humanoid.Health = 30
end
end
end
Brick.Touched:connect(PlayerTouched)
wait(1)
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
if LivesA == "Lives: 3" then
LivesA = "Lives: 2"
Parent.Humanoid.Health = 20
end
end
end
Brick.Touched:connect(PlayerTouched)
wait (1)
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
if LivesA == "Lives: 2" then
LivesA = "Lives: 1"
Parent.Humanoid.Health = 10
end
end
end
Brick.Touched:connect(PlayerTouched)
wait(1)
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
if LivesA == "Lives: 1" then
LivesA = "Lives: 0"
Parent.Humanoid.Health = 0
end
end
end
Brick.Touched:connect(PlayerTouched)
wait(1)
if LivesA == "Lives: 0" then
LivesA = "Game Over.."
SpinningSpeed = 0
end
EDIT: ANSWERED READ ANSWERS

5 comments
Use :Connect() instead of :connect() for newer work.
give me your discord so i can try to help you
give me yours
mine's mrwan#2646
sent