I wrote a script to make the player take 1 damage every .1 seconds. I thought using a while true do would be a correct way to do it, but apparently it isn't
local SP= script.Parent local function steppedOn(part) local Parent = part.Parent if game.Players:GetPlayerFromCharacter(Parent) then while true do Parent.Humanoid:TakeDamage(1) wait(.1) end end end
You didn't link the function 'steppedOn' with the Touched event!
This is how you use the Touched event: SP.Touched:connect(steppedOn)
Add the line above to your code and it should work just fine!
However, that while loop should loop forever since there is no 'break' to it. To counter this problem, you must add 'break' with an if statement checking: if the player's health is greater than 0, take 1 damage; otherwise, break the loop since it has no use anymore. This is how:
while true do if Parent.Humanoid.Health > 0 then Parent.Humanoid:TakeDamage(1) else break end wait(.1) end
Also, you should use Debounce to prevent overlapping the damage. http://wiki.roblox.com/index.php?title=Debounce