Right now, for some odd reason, my touch detector isn’t working right. I want to make a system so that any buildings within 15 - 10 studs away will have 10% of the morph's damage value taken off, 9 - 5 will have 50% of the morph's damage value taken off, and any buildings 4 - 0 studs will have the full amount taken off, every 0.5 seconds. Currently, you have to jump against the building to deal any damage. Which is a problem, considering I have a no jump script. Each building has an int value called health, and the morph on the player has a value called damage. Please help me implement such a system! Script:
game.Players.PlayerAdded:Connect(function(player)
local debris = player:WaitForChild("leaderstats").Debris
player.CharacterAdded:Connect(function(character)
for __, Part in pairs(character:GetChildren()) do
if Part:IsA("BasePart") then
Part.Touched:Connect(function(hit)
if hit:FindFirstAncestor("Buildings") then
print(hit)
print(hit:FindFirstAncestor("Building"):FindFirstChild("Health").Value)
hit:FindFirstAncestor("Building"):FindFirstChild("Health").Value = hit:FindFirstAncestor("Building"):FindFirstChild("Health").Value - character:FindFirstChild("Morph").Damage.Value
if hit:FindFirstAncestor("Building"):FindFirstChild("Health").Value <= 0 then
hit:FindFirstAncestor("Building"):Destroy()
print("Building destroyed.")
end
player.leaderstats.Debris.Value = player.leaderstats.Debris.Value + math.random(10,15)
end
end)
end
end
end)
end)
Any way this is possible? I will be releasing an update for my game, and this is the last thing I need to finish.

6 comments
Side note: I need this because I will be adding a no jump script!
You can try to put wait() at line 4.. or make the morph damage lower.. I don't know what your script saying :V sorry ;(
the formatting is burning my eyes
Yeah, SH formatting is not the best.
I think its possible... I'm looking over how at the moment...
Thx!