So i encountered a bug in a project i was working on where you get one point when you step on a block but when i die the script breaks and i dont get points for stepping on the blocks anymore
local platform = script.Parent
local isTouched = false
local function fade()
if isTouched == false then
isTouched = true
for count = 1, 10 do
platform.Transparency = count / 10
wait(0.1)
end
platform.CanCollide = false
wait(3)
platform.CanCollide = true
platform.Transparency = 0
isTouched = false
end
end
platform.Touched:Connect(fade)
local Players = game:GetService("Players")
local function onPlayerAdded(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0
points.Parent = leaderstats
end
Players.PlayerAdded:Connect(onPlayerAdded)
local wasTouched = false
local function pointsAdded ()
if wasTouched == false then
wasTouched = true
local playerList = Players:GetPlayers()
for currentPlayer = 1, #playerList do
local player = playerList[currentPlayer]
local points = player.leaderstats.Points
points.Value = points.Value + 1
wait(5)
wasTouched = false
end
end
end
platform.Touched:Connect(pointsAdded)