and so hello to all the scriptwriters and developers, I would like to ask for help when a player trains in a zone where there is a boost to the power of x 2 and he moves away from the place and can train all over the map help fix a bug my script
local character = script.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local root = character.HumanoidRootPart
local radius = 25
local strength = player.Strength
local psp = player.Psp
local endurance = player.Endurance
local sMulti = player.ZoneMulti
local pMulti = player.pZoneMulti
local eMulti = player.eZoneMulti
-- ZONE ROOTS
local rockRoot = game.Workspace.RockZone.Rock
local pspRoot = game.Workspace.TestPsychicZone.Rock
local hospitalRoot = game.Workspace.HospitalZone.Abulance
local testRoot = game.Workspace.Pear.TEST
while wait(0.0000000001) do
local rockDistance = (root.Position - rockRoot.Position).Magnitude
local hospitalDistance = (root.Position - hospitalRoot.Position).Magnitude
local pspDistance = (root.Position - pspRoot.Position).Magnitude
local testDistance = (root.Position - testRoot.Position).Magnitude
-- CHECK DISTANCE
if rockDistance <= radius then
if strength.Value >= 10 then
sMulti.Value = 2
end
else
if sMulti.Value == 2 then
sMulti.Value = 1
end
end
if hospitalDistance <= radius then
if endurance.Value >= 10 then
eMulti.Value = 2
end
else
if eMulti.Value == 2 then
eMulti.Value = 1
end
end
if pspDistance <= radius then
if psp.Value >= 10 then
pMulti.Value = 2
end
else
if pMulti.Value == 2 then
pMulti.Value = 1
end
end
if testDistance <= radius then
if strength.Value >= 10 then
sMulti.Value = 20
end
else
if sMulti.Value == 10 then
sMulti.Value = 2
end
end
end
If the magnitude for each zone is more than the range, it should be set to default value instantly, don’t check if the player has the zone boost before setting to normal value
When player is not in the range, don’t put an if statement to check if the multiplier is active (x2 or more) before putting it back to 1, instead just put it back to 1 regardless of what multiplier the player has
If your translator still doesn’t work, tell me
-- CHECK DISTANCE
if rockDistance <= radius then
if strength.Value >= 10 then
sMulti.Value = 2
end
else
if sMulti.Value == 2 then -- remove
sMulti.Value = 1
end -- remove
end
if hospitalDistance <= radius then
if endurance.Value >= 10 then
eMulti.Value = 2
end
else
if eMulti.Value == 2 then-- remove
eMulti.Value = 1
end -- remove
end
if pspDistance <= radius then
if psp.Value >= 10 then
pMulti.Value = 2
end
else
if pMulti.Value == 2 then --remove
pMulti.Value = 1
end -- remove
end
if testDistance <= radius then
if strength.Value >= 10 then
sMulti.Value = 20
end
else
if sMulti.Value == 10 then-- remove
sMulti.Value = 2
end-- remove
end
end
Basically for each else remove the if statement, it will remove the boost even if it is not applied
After careful thought, I think this is the issue. You are setting it to the boost multi of rockif test is out of range, you should change that to 1
If not then I will try to replicate the zones and test it
while wait(0.0000000001) do
-- Reset multipliers
sMulti.Value = 1
pMulti.Value = 1
eMulti.Value = 1
-- Calculate distances
local rockDistance = (root.Position - rockRoot.Position).Magnitude
local hospitalDistance = (root.Position - hospitalRoot.Position).Magnitude
local pspDistance = (root.Position - pspRoot.Position).Magnitude
local testDistance = (root.Position - testRoot.Position).Magnitude
-- Apply multipliers based on location
if rockDistance <= radius and strength.Value >= 10 then
sMulti.Value = 2
end
if hospitalDistance <= radius and endurance.Value >= 10 then
eMulti.Value = 2
end
if pspDistance <= radius and psp.Value >= 10 then
pMulti.Value = 2
end
if testDistance <= radius and strength.Value >= 10 then
sMulti.Value = 20
end
end
might be due to the fact that the multipliers are not reset when the player moves out of a zone. This can be fixed by resetting all multipliers to 1 at the start of each loop iteration, and then applying the appropriate multipliers based on the player’s location