Rihlsul

Roblox - Death on CrackedLava Terrain Script

May 20th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. -- Roblox Script to trigger/detect when players walk on CrackedLava terrain and kill them
  2. -- Create this as a new Script on your Terrain object.
  3.  
  4. function onTheLava(character)
  5.     local checkRay = Ray.new(character.HumanoidRootPart.Position, Vector3.new(0, -50, 0))
  6.     local gridPart, intersect, surface, material = game.Workspace:FindPartOnRay(checkRay,nil,true,true)
  7.     if (material.Name == "CrackedLava") then
  8.         return true
  9.     end
  10.     return false
  11. end
  12.  
  13. function onTouched(hit)
  14.     if hit.Parent then
  15.         if hit.Parent:FindFirstChild("Humanoid") then
  16.             local vPlayer = game.Players:playerFromCharacter(hit.Parent:FindFirstChild("Humanoid").Parent)
  17.             if (vPlayer ~= nil) then
  18.                 local char = hit.Parent:FindFirstChild("Humanoid").Parent
  19.                 if onTheLava(char) then
  20.                     hit.Parent.Humanoid.Health = 0
  21.                 end
  22.             end
  23.         end
  24.     end
  25. end
  26.  
  27. script.Parent.Touched:connect(onTouched)
Add Comment
Please, Sign In to add comment