you could simply check if there is any zones in the array returned by getpartinparts, if yes, set speed to 30, if no, set to 15.
Thats just a more complicated and laggier version of what I said ;-;
you could simply check if there is any zones in the array returned by getpartinparts, if yes, set speed to 30, if no, set to 15.
Thats just a more complicated and laggier version of what I said ;-;
I guess youâd have to use the zone:findPlayer(player)
function in ZonePlus on any overlapping zones and checking if itâs true or not. As for how youâd check for overlapping zones, uh kinda no idea. Good luck though.
Maybe try using GetTouchingParts on the player HumanoidRootPart instead
huh, im not sure how that one helps, can you explain a bit more?
i suppose, trying something like that rn
This would work ^, try looking into it
Firstly, lemme make sure I understand your goal correctly.
When a player is in any (or multiple) speed zone(s), they should have 30 speed, and if not, they should have 15, correct?
If so, all you have to do is check if they are currently overlapping with any speed zone (via get part in parts), then, using an if statement, set their speed to either 15 or 30
as an alternate solution, you can also treat all speed parts as one by grouping them together to be a singular model, that might work too (idk if zoneplus functions like that but it seems like it does)
it does but i gotta move the part a lot
so if thereâs overlapping i set it to 30?? do i do it when playerenter or when player exit?
I donât believe that matters
I think youâre a bit stuck in the idea of âoverlapping or notâ . Instead, think of all of the zones as a singular, irregularly shaped zone. Now, all you have to do is check if you are in the zone or not to determine if the speed should be 30. To do this, simply check if you are touching ANY of the zones, if yes, your speed is 30, if no, its 15. This check should be done during both exiting and entering the zones.
(I just realized my previous reponse might have been worded in a slightly confusing way lol)
I do believe getpartsinpart might not be the most efficient, so another way would, yet again, be to use a variable to store how many zones you are currently in, and upon entry/exit of a zone, check if it changes between 0 and other numbers to determine wether to set the speed to 30 or 15
well instead of moving the model i will have to change every script that moves the model to somehow get itâs hitbox and move it, is there like any alternatives to groups/models, like tagging instances?
Due to the way zoneplus functions, I donât think thatâd work
I donât see why you canât just move the models, shouldnât zoneplus automatically update the location? (I havenât used it in 3 years, so im unsure)
yeah it does, but the hitbox is parented to the model, which moves with the model, when the model moves, the hitbox moves and so does the zone, i would need to parent all the hitboxes in a folder
oh, I see what you mean.
then this might not be the best solution, you could also do the other way I mentioned
canât believe how complicated the problem actually is, ill try it out i guess
I found a solution to your problem!
Maybe try this code:
local Players = game:GetService("Players")
local zones = {workspace.zone1,workspace.zone2}
local function zoneCheck(character)
local humanoid = character:FindFirstChild("Humanoid")
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local touchingParts = workspace:GetPartsInPart(humanoidRootPart)
for i,part in pairs(touchingParts) do
if table.find(zones,part) then
humanoid.WalkSpeed = 30
return
else
humanoid.WalkSpeed = 15
end
end
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
while wait(0.2) do
zoneCheck(character)
end
end)
end)
I just threw it together idk if its flawless or anything.
Script is in ServerScriptService btw!
local Zone = require(game.ReplicatedStorage.Zone)
local zones = (find a way to put all the zones in an array)
local players = (table of players with their player object as the key and the value being 0)
for _, v in zones do
tempZone = Zone.new(v)
tempZone.playerEntered:Connect(function(plr)
players[plr] += 1
if players[plr] > 0 then
plr.Character.Humanoid.WalkSpeed = 30
end
end)
tempZone.playerExited:Connect(function(plr)
players[plr] -= 1
if players[plr] == 0 then
plr.Character.Humanoid.Walkspeed = 15
end
end)
end
this might not function completely correctly since i typed it in forums not studios
alright so it worked (i think)
local Zone = require(game.ReplicatedStorage.Zone)
local zone = Zone.new(script.Parent)
zone.playerEntered:Connect(function(plr)
plr.Zones.Value += 1
plr.Character.Humanoid.WalkSpeed = 30
end)
zone.playerExited:Connect(function(plr)
plr.Zones.Value -= 1
if plr.Zones.Value == 0 then
plr.Character.Humanoid.WalkSpeed = 15
else
plr.Character.Humanoid.WalkSpeed = 30
end
end)
im just about sick of this problem, lmk if my logic is wrong or there might be something i didnât account for. sorry @Nico_Nic77 Iâm sure yours would work, but this is a solution i am willing to accept
why no âsolutionâ for me /j
I donât believe theres a need for the else statement in the exited, but yea
also I would suggest keeping it all in 1 script since having many serverscripts would be confusing (though this is your choice)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.