Boss is located at the workspace. Image: And yes, I’m actually making hulk the killer but better with shops, etc.
I just placed this into my script and your humanoid Quotations are not working
I just realized that lol, they would have to make it " " or ’ '.
Are they using the codeblock thingy or something?? ``
I dont know, but hopefully the figure it out soon
Tried ’ ', didn’t change or fix anything
They are two different things paste this into your script:
local humanoid = game.Workspace.Boss:FindFirstChild("Humanoid")
local cash = 100
local leaderstats = game.ServerScriptService.leaderstats
local sound = game.Workspace.cashregistersound
local debounce = false
local boss = game.Workspace.Boss
if debounce == false then
humanoid.Died:Connect(function()
if humanoid.Health == 0 then
debounce = true
for i, players in pairs(game.Players:GetPlayers()) do
players.leaderstats.Points.Value += cash
wait(2)
sound.Playing = true
wait(3)
sound.Playing = false
debounce = false
end
end
end)
end
You will need to know how your respawn script works, does it recreate the entire Boss model? How is the entire Boss model destroyed? Or do they build up. I’d check in the respawn script and also look in the workspace as you’re playing to see what is getting cloned. Also, your script you moved in there will probably need a WaitForChild in case some items aren’t created yet when the script runs.
seems like you guys know what your talking about so im just going to go back to developing
I have no clue I’ve just like started developing again this month this is my first time on here in ages
I think you just got programmer rank lol ( off topic )
I’ve had it ages just this flair thingy was not a thing when I joined
I’m more of a web developer now so I’ll keep this one
did they ever get a solution? Because ive been gone for over a hour lol
Found a few issues:
- Humanoid.Died is unreliable. Per API reference, works locally only (not a server side NPC)
- If the humanoid has died, is there any point in checking health?
- Should check for health “<=” to 0
- As already mentioned, nothing trying to identify the respawn boss.
Here’s how I’d do it. This script would go in ServerScriptService. Not tested, as I don’t have a boss.:
local RunService = game:GetService("RunService")
local cash = 100
local leaderstats = game.ServerScriptService.leaderstats
local sound = game.Workspace.cashregistersound
local boss = nil
local function bossDied ()
for i, players in pairs(game.Players:GetPlayers()) do
players.leaderstats.Points.Value += cash
wait(2)
sound.Playing = true
wait(3)
sound.Playing = false
end
end
RunService.Heartbeat:Connect(function ()
if game.Workspace:FindFirstChild("Boss") then
boss = game.Workspace.Boss.Humanoid
if boss and boss.Health <= 0 then
coroutine.wrap(bossDied)
boss:Destroy()
end
end
end)
EDIT: forgot about all the waits in the died function… have to use a coroutine I think.
Tested this, and found another error "ServerScriptService.Script:20: attempt to index nil with ‘Health’. " and the error starts to print alot after i killed the boss.
Even though if I should change to WaitForChild. It still won’t work since it gets warning like this
Infinite yield possible on 'Workspace.Boss:WaitForChild(“Humanoid”)
As a newbie scripter, this is the weirdest script I’ve stumbled into, since after fixing the error and there goes another error.
The problem is simple. When one humanoid dies the character get removed and one new comes the humanoid you tried to target is not the new one. Like if he got removed you have to find the new one again.
Ahh, I think I see my mistake. The “WaitForChild” is misbehaving with Heartbeat. I’ll fix that real quick.
As I understand it, Heartbeat calls the check 60 times a second, and the wait holds the checks all to be released at once. No need to hold onto them. Now if the Humanoid is not there, the code will ditch it!
And that’s coding for you! LOL, fix one thing, break something else.