Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

can terrain terrains affect players using a script?

Asked by
0msh 333 Moderation Voter
6 years ago
Edited 6 years ago

can terrains affect players using scripts? For example, if a player walks on a "cracked lava" terrain, the player loses 10 health every second, is that possible?

1 answer

Log in to vote
2
Answered by 6 years ago

Yes, it is possible to affect players by terrain using scripts. You can do this using FloorMaterial and a .Changed event (Or :GetPropertyChangedSignal()).

Here’s an example of damaging a player when they touch the lava terrain :

somehumanoid:GetPropertyChangedSignal(“FloorMaterial”):Connect(function()
if somehumanoid.FloorMaterial = “Lava” then
somehumanoid:TakeDamage(10)
end
end)

This script fires every time the humanoid’s FloorMaterial changes. It checks if the player is on the lava terrain or not. If it is, the script damages the player, otherwise it does nothing.

Also note that this is a very basic example, which means there are some things missing/inaccurate in the example. Don’t think you can just copy-paste this script. :3

Hoped this helped!

Ad

Answer this question