I am in the process of making some sort of Laser Tag game. It requires there to be enemy spawns that can be disabled upon taking enough damage. Here is what I have now-
Keep in mind that I’m new to scripting. All help is appreciated. Thanks! Im slightly stumped of how to do this, but the example script is something along the lines of what Im looking for.
So basically the idea is that the opposing team has bases. You can shoot these bases, and once they’ve been shot enough a spawn point for their team is disabled. I’m trying to use a humanoid to record the damage (I don’t know if this is the right way or not).
But, why make the effort to make an extra BoolValue if the MaxHealth propertie is a thing? It‘s like making a ColorValue while there is already a Color propertie on the Part
Why record it, if you can read the Health propertie? May you explain more?
You’ll want to react every time the base takes damage, and then check if the health is below or at 0. If that’s the case you can set the Enabled property of SpawnLocation to false, which should disable it from working.
I’m not exactly sure what way to do it, but I thought if I just used a humanoids health to like hold the health for the base and recognise damage being taken?
Sorry for not being well specific.
Yea, that‘s correct, but you also need to add a loop
trying to explain it in a beginner friendly way, your code will run as soon as the world spawns, but then it won‘t ever work afterway. Also, you should insert the code in the ServerScriptService. Leaving it in the workspace will allow hackers to exploit and delete the script.
If you want the script to be really performant, try events instead of loops (game:GetService(“Players“).PlayerAdded ; this is an event for example)
Its not showing (I snipped it) here but there’s two errors
On the => it says: 'expected then when parsing if statement got ‘=’
And on the then: Expected identifier when parsing expression got ‘then’
Thanks a lot! I will come back to this tomorrow, as its past midnight for me… I truly appreciate everyone’s help in aiding me to make my dreams come true!
local Humanoid = script.Parent:FindFirstChild("Humanoid")
local SpawnPoint = workspace:FindFirstChild("SpawnPoint")
Humanoid.HealthChanged:Connect(function(Health)
if Health <= 50 then
SpawnPoint.Enabled = false
end
end)
While that is certainly a way to help, you should never give a new scripter a code to copy-paste. The goal of a topic is to help the scripter finding a solution + understand the new found solution. By just giving him the code without explaining anything, you aren‘t really helping @Ckicken_KId.
Also, same thing as I told before, this should be in the ServerScriptService, not in the player‘s Character Model
It’s an NPC, so the script is fine inside the model itself. You’re right about providing more info regarding potential solutions so I’ve linked the HealthChanged event article.