I have a large game that features the Smooth Terrain feature. However, what I would like to do is light a player on fire when they touch Cracked Lava terrain, as described in the following pseudocode:
while true do for plr in game.Players do if plr is touching CrackedLava terrain -- what I need help with (set plr on fire) -- I know how to do this and do not need help end end wait(0.1) end
Basically, that is what I need to do. However, it probably will not need the loop, as that could cause lag. Here is another method I came up with that probably won't work, but I can't try it, as I don't actually know how to do some things.
let terrain = game.Terrain for (voxel of type "CrackedLava") in terrain do -- don't know if something like this is possible (surround terrain with part named "LavaPart") -- don't know how to do this either end for (part named "LavaPart") -- know how to do this (insert script from ServerScriptService into part) -- know how to do this end
That might work, but still would have lag on older machines, most likely even more than the initial method of covering it in bricks. It would also need to have a way to gather all the Smooth Terrain voxels. However, it does solve two initial problems, and an answer like this would be acceptable. (I really just want to not spend a really long time covering up my world with parts.)
So, can anyone please rewrite one of these examples into actual ROBLOX Lua or come up with a completely different method that works? (Please explain any code, as I am trying to learn some stuff by making ROBLOX games)
I know this is probably not what you wanted but using bricks on top of the desired terrain will still work, just create the same script that checks if the player is touching the brick that is just above the terrain. (Set them to 1 transparency and false cancollide)
I know a way you could check the material the humanoid is standing on, but if the humaniod's lying down, it won't work.The following script will make the players take damage if they're standing on lava(put it in the starterpack): --Begin-- local Humanoid = game.Players.LocalPlayer.Character.Humanoid while true do local Material = Humanoid.FloorMaterial if Material == Enum.Material.CrackedLava then Humanoid:TakeDamage(20) end wait(.1) end --End-- Even though this would lead to a swift death, I hope you find it useful.