So, i’m not really a great scripter, actually i’m not a scripter at all, I want to make a glass that you can shoot and break, using a humanoid part with 1 hp and when the hp is gone the part should disappear, I’m really bad at scripting, can anyone help me ?
Here you go:
Sample code:
--I guess just put this inside the Glass Part
local Humanoid = script.Parent.Humanoid
Humanoid.Died:Connect(function()
script.Parent:Destroy()
end)
That’s not really effective, considering how humanoids can spike up the memory a lot(by the way, old games used to use this technique). If you decide to create breakable glass, consider utilizing the raycast of the shot and the followed by a function that breaks it, with just a simple Destroy
function.
I’m just doing a game for me and my friends, I’m trying to do like a rainbow six siege type of game but thank you very much guys
oh and forgot to add this
can u pls play this sound 4757900430 when the window breaks or something, thank you very much
First, add a sound inside the glass part. Set the id to the id. then:
--I guess just put this inside the Glass Part
local Humanoid = script.Parent.Humanoid
local sound = script.Parent:WaitForChild("Sound") -- so the sound inside the glass part, don't rename it
sound.PlayOnRemove = true
Humanoid.Died:Connect(function()
script.Parent:Destroy()
end)
Won’t work, as the Sound
will also be destroyed since it’s Parented into the Part
Enable PlayOnRemove
on the Sound
object to fix it I believe
I never took that into consideration, thanks
Also, you might want to set the range property of the sound (look for the one set to 10000) to like 10.