Help to fix script

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
2 Likes

Can you specify what bug are you experiencing?

1 Like

when a player pumps power, for example, he gets x 40 and moves away from this place and gets this boost all over the map

1 Like

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

1 Like

I did not understand my translator probably did not translate correctly can you explain what you are talking about? I have distances getting strength

1 Like

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

1 Like

can you describe the problem in the script I’m new to writing scripts just now I made this script


-- 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

It doesn’t work, I tested it anyway, I get it all over the map

1 Like

nevermind
dadsdadawdsdaddadadd

1 Like

Can you help fix the problem? or not?

please help I can’t fix it I spent 2 days

please help or let me know if you don’t want to help

After careful thought, I think this is the issue. You are setting it to the boost multi of rock if test is out of range, you should change that to 1
If not then I will try to replicate the zones and test it

it doesn’t work, I tried and tested it. can you help me fix 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
1 Like

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

did it worked for u? or did not?

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.