Okay, so I am a terrible scripter - I am just starting to learn... This seemed simple enough to do but clearly it's not. What's wrong with my script?
I wanted to make the ocean in a game of mine deadly to the touch. But as I am slowly but surely making a very realistic game, I used terrain water. So a normal script is not going to work, obviously. Damaging health is easy enough, and I haven't perfected that yet, so don't judge.
How do you get a script to recognize contact with Terrain? Here's my script:
function onTouched(Player1)
local player = game.LocalPlayers.Player1
local humanoid = player:findFirstChild(Humanoid)
if humanoid then
if humanoid.Health > 0 then
workspace.Player.Humanoid:TakeDamage(15)
end
end
end
if script.Parent:IsA(workspace.Terrain) then
script.Parent.Touched:connect(onTouched)
end
PS: A new fully-written script would be nice, thanks! ;P |