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

can i have help with a height script?

Asked by 10 years ago

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

2 answers

Log in to vote
0
Answered by
emite1000 335 Moderation Voter
10 years ago

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

Ad
Log in to vote
0
Answered by
1N0body 206 Moderation Voter
10 years ago
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.

Answer this question