My script only works one time

The script i’m talking about located in the workspace, that’s it. ( sorry for bad grammar )

Thanks, now I know what to do, because if it was located in the boss then It would be something else. let me see how this will work out

while wait() will be located at line 15 or somewhere else?

line 15 aka where you put wait(sound.length)

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
while wait() do
if debounce == false then
humanoid.Died:Connect(function()
if humanoid.Health == 0 then -- you dont really need this because getting .died means that the player/boss has died
debounce = true
for i, players in pairs(game.Players:GetPlayers()) do
players.leaderstats.Points.Value += cash
end
wait(2) -- I would recommend deleting this but you dont have to
sound.Playing = true
wait(sound.length) -- Instead of .length change it to the original wait time
sound.Playing = false
debounce = false
end -- if you end up deleting if humanoid.Health == 0 then just delete this end
end)
end
end

I dont know if this script works the way you want it to, but I think it should

Tested this, after I killed the boss, points reward value is randomly counted aka I received 28000 instead of 100.

1 Like

common error. let me fix that, sorry about that

1 Like

wait a question, does the boss respawn or not?

1 Like

Yes, It does since I’m testing boss if the script will continue to work or it will end up working only at the one time.

1 Like

Good idea, why not put this script in the Boss model that gets respawned already.

1 Like

That would work better, then the script would also respawn with the boss

1 Like

Thanks for telling me guys. I would try this.

1 Like

also you can get rid of the while wait do, (and one of the ends) because it will just keep on repeating it

1 Like

I would use this script instead of the while wait function one.

1 Like

Edit: It does same thing, script still work only at one time.

1 Like

have you killed the boss multiple times? or just once?

1 Like

I killed the boss multiple times, only one time still work, rest of it doesn’t.

1 Like

wait so is the script in the boss?

1 Like

Yep, just put the script into the boss model, doesn’t fix anything.

1 Like

can you send a picture of the inside of the boss? and where the boss is located?

1 Like