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

It will not print or kill my player, where did I go wrong?

Asked by 4 years ago
01local region = Region3.new(Vector3.new(5,0,5), Vector3.new(15,15,15))
02 
03local part = Instance.new("Part")
04part.Anchored = true
05part.Size = region.Size
06part.Parent = game.Workspace
07part.CanCollide = false
08part.Transparency = 0.5
09 
10while true do
11    wait()
12    local partsInRegion = workspace:FindPartsInRegion3(region, part, 1000)
13    for i, part in pairs(partsInRegion) do
14        if part.Parent:FindFirstChild("Humanoid") ~= nil then
15            print("He's in the region, we got you: "..part.Parent.Name)
16            local char = part.Parent
17            char.Humanoid:TakeDamage(char.Humanoid.MaxHealth)
18        end
19    end
20end

This Region3 script creates a part and is supposed to, when touched, print the phrase shown above and kill the player, I am following a tutorial by TheDevKing on youtube and I was sure I followed his instructions exactly, can someone please tell me whats wrong, so that I can find a fix? (I posted this yesterday with no answers, please help me guys)

2 answers

Log in to vote
0
Answered by
DevingDev 346 Moderation Voter
4 years ago
Edited 4 years ago

The problem with your code was that the Region you had created at line 1 was not the same Position as the hitbox part you had created on line 3.

I tried creating objects for the Min and Max Vector for the region. That resulted both of them being outside of the hitbox part.

You're now not required to having a hitbox part. You're now defining the Position, and Size as a variable at the top.

You're free to remove the code from line 12 to line 18 if you want to. It'll only provide you a means of debugging.

01-- Services
02local playersService = game:GetService("Players")
03 
04local sizeX, sizeY, sizeZ = 10, 10, 10
05local hitboxPosition = Vector3.new(0, 5, 0)
06 
07local upperCorner = hitboxPosition + Vector3.new(sizeX/2, sizeY/2, sizeZ/2)
08local lowerCorner = hitboxPosition - Vector3.new(sizeX/2, sizeY/2, sizeZ/2)
09 
10local region = Region3.new(lowerCorner, upperCorner)
11 
12local hitbox = Instance.new("Part")
13hitbox.Parent = workspace
14hitbox.Anchored = true
15hitbox.Size = region.Size
View all 31 lines...
Ad
Log in to vote
0
Answered by 4 years ago

I think your mistake is about humanoid.As you do in the script,if your humanoid is not nil.Then kill the player and print.Your humanoid might be nil.You can put wait(3) at the start of the script so your humanoid and character can load.

0
ok thx MOREHOURSOFFUN 104 — 4y

Answer this question