Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

can i have help with a height script?

How would I make a sound play when a player dies under a certain height of 200 studs?

2 answers

On the Died event, check if the Player's Y Position is -200 or less. If true, play the sound you want.

calculatefrom =       -- Here insert the location from where to calculate the distance.(I guess it's           omething like game.Workspace.Baseplate)
distance = 200 -- the distance


function calculate(player)
--Main trick here is this ".magnitude"
math = ( player - calculatefrom.Position).magnitude
if math <=  distance then
 return false 
else
return true 
end

for _,obj in pairs(game.Players:GetPlayers)
if obj.Character then
pizza  = obj.Character:WaitForChild('Humanoid')
pizza.Died:connect(function()
print 'NOO' -- :D
if calculate(pizza.Parent.Torso) == true then
sadsong = game.Lighting:findFirstChild('SOUNDNAMEHERE') -- put the deisred sound to play in the lighting and it's name over there.
sadsong.IsPlaying = true
-- you can do any other stuff here
end
end)
end
end

I didn't tested the code so it may require more maintanence.

This discussion is preserved as it was. New answers, comments, and votes are closed.