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