That’s another way you can do however, like I said, it won’t fully detect if every bodypart is within it. A body part could be touching the Region3 and it would detect it, but the whole body part might not be fully inside the Region3. With some simple math, you can get the distance between the center of a Region3 to an edge. Then you can set the magnitude range to that distance.
Dont need, is a power Simulator, even if he is not fully inside he will start receiving status, and if he is not strong enough to be there he will take damage anyway, there is no reason for him to be fully inside
Then I suggest, you use Region3.
yeah, but magnitude isn’t better becouse it only search a circle area, but if he want to make two areas, one circle like in photo and one triangle or cubic? it will break so Region3 is better than magnitude
Another question, you said “no, only they can detect the script in it, but they can if ur script have a RemoteEvent or RemoteFunction in it”, iam using BlindEvent, because the stats arent on folder, so i need use ServeScriptService to make the Training Script
Magnitude isn’t for searching. Like I said, it’s the length of a vector. You can always get the magnitude from the center of the part(part.CFrame) to the edge of a part(part.Size.X / 2). You can use that magnitude as a range.
BlindEvent? that dosnt exists, but if there isn’t any RemoteEvents or RemoteFunctions that change stats, magnitude and Region3 are great
Instead of connecting the function to heartbeat, in this case I think it’s better to use a while loop and wait for heartbeat to ensure the functions don’t overlap and a memory leak occurs by spawning infinite coroutines.
Your code:
local RS = game:GetService('RunService')
RS.Heartbeat:Connect(function()
print('example')
end)
My code:
while true do
game:GetService('RunService').Heartbeat:Wait() -- waits for heartbeat so we're waiting *just* the right amount, no more no less
-- code for detecting players in the part
end
Edit: just FYI, wait(1) can actually wait much longer than 1 second since it not only delays a second, but it also puts the process at the bottom of the priority list.
BindableEvent, sorry i write wrong, and i cant FireServer on Part, because Part is on server, so i used Bindable event, iam only firing between servers
ok, so there can’t a exploit put infinite stats, so Region3 should be great
BindableEvent is for server->server communication and client->client communication. You cannot communicate with the server if your on the client using a BindableEvent.
Ik, but the Region3 will be inside part, and Part are on server, i cant use remot event to FireServer on part
true, if u want the stats to show on a gui in client u need to use RemoteEvents and that can be hackable only to show what stats u have, not to incrase its stats on the other Clients or Server
Yes, see
local touching = false
local StartTraining = game.Workspace:WaitForChild("StartTraining")
local StopTraining = game.Workspace:WaitForChild("StopTraining")
local module = {}
function module.Get()
return touching
end
function module.Training(player,amount,Part,Stat,Touchings)
touching = Touchings
if touching then
StartTraining:Fire(player,amount,Part,Stat)
else
end
end
return module
On ServerScriptService
--training events--
local AutoTraining = {}
local function increaseStats(Player,Amount,Stat)
while true do
wait(1)
if not AutoTraining[Player.UserId] then return end
ServerData[Player.UserId]["Stats"][""..Stat]["Value"] = ServerData[Player.UserId]["Stats"][""..Stat]["Value"] + 50
print(ServerData[Player.UserId]["Stats"][""..Stat]["Value"])
end
end
local function checkIsTrainingArea(player,Amount,Part,Stat)
print("checkingg")
print(Amount)
local touching = Part:GetTouchingParts()
local ValidPosition = false
for i=1,#touching do
if touching[i] == player.Character.HumanoidRootPart then
ValidPosition = true
break
end
end
if ValidPosition == true then
AutoTraining[player.UserId] = true
increaseStats(player,Amount,Stat)
end
ValidPosition = nil
touching = nil
end
local function stopTrainingF(Player,Part)
local touching = Part:GetTouchingParts()
local ValidPosition = false
for i=1,#touching do
if touching[i] == Player.HumanoidRootPart then
ValidPosition = true
break
end
end
if ValidPosition == true then
AutoTraining[Player.UserId] = false
end
ValidPosition = nil
touching = nil
end
StartTraining.Event:Connect(checkIsTrainingArea)
Thanks man i will do that :), very thanks
Some place demo of safe zone Zone+ (outdated) - Roblox (uncopylocked)
However you can modify that script and remove the ForceField and change something else.
too complex for me, i cant understand that, but thanks for post that
And this is more to check if player is inside a area when you want, in my case player can leave and enter all times on the training zones, so i need use While
Create a part of any shape(or a group of parts) and name them “X”, put them in one model.
Create a region3 and use model:GetBoundingBox() to get a rough size of the area.
If a player is in that rough area then raycast downwards from their HumanoidRootPart. If the ray hits a part called “X” and they aren’t too far from the model heightwise then you can safely say that the player is in that area.
If you do not know how to raycast then I strongly suggest you do.
:GetPartsInPart
30limit