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

Can I make a safe zone without using maxHealth?

Asked by 4 years ago
Edited 4 years ago

Ive only tried using health, but I find it annoying when the damage/damageui pops up. I want it to make a bubble/protection bubble around the player, just like spawn protection in games! Is there a way to not use

1math.huge
1math.floor

Do I need to access the humanoid for this? I tried looking through the humanoid properties, just health and maxHealth.

Please and thank you!

0
What weapons are you using? You can make them do 0 damage if the player is in the safe zone. srimmbow 241 — 4y
0
@srimmbow so im guessing a boolean value will be used for this, I'm just doing some preparing until I add my punch tool to my weight lifting game, I guess I could do that. Make a int value for the damage? alabamalover90001 2 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

do

1script.Parent.Touched.Connect(function(hit)
2if hit.Parent.Humanoid.Health <= 100 then
3hit.Parent.Humanoid.Health = 100
0
add end because you didn't ended "if" ErktikyYT 89 — 4y
0
ok catsalt29 57 — 4y
Ad
Log in to vote
0
Answered by
Despayr 505 Moderation Voter
4 years ago

If you are making a safe zone, then perhaps Region3? Here is a script I just wrote. I wasn't in studio, so feel free to test it. The general idea is here, so have a go.

Before damaging the player, you can check if they are in the region3. Example

We are going to have a singular function to handle all of the damage. This makes it so we only need to write the region3 check once.

01local replicatedStorage = game:GetService("ReplicatedStorage")
02local remoteEvent = replicatedStorage:WaitForChild("RemoteEvent")
03 
04 
05--Region3 Safezone
06local min = part.Position - (0.5 * part.Size)
07local max = part.Position + (0.5 * part.Size)
08local region = Region3.new(min, max)
09 
10 
11--Global function to handle the damage
12local function damageTarget(humanoid, enemy, amount)
13    if humanoid == nil then return end
14    if enemy == nil then return end
15 
View all 68 lines...

For more information, check here for region3 https://developer.roblox.com/en-us/api-reference/function/WorldRoot/FindPartsInRegion3

Answer this question