Problem with x2 zone, help is appreciated!

Hey!

I have a script (by alaaeiou). The script is supposed to give a player x2 stats (Time) when they step on a part and if they step off they only gain x1 but, it won’t work.


There is a script parented to a brick in the workspace:
image

Inside the script:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local character = hit.Parent
        local multiplier = Instance.new("IntValue",character)
        multiplier.Name = "Multiplier"
        multiplier.Value = 10
    end
end)

script.Parent.TouchEnded:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local character = hit.Parent
        character.Multiplier.Value = 1
    end
end)

There is a separate script in StarterPlayer>StarterCharacterScripts that is in charge of adding stats.

	local multiplier = character:WaitForChild("Multiplier")
	while not hasDied and not CheckSpawnRegion() do
		timeAlive.Value += multiplier.Value

^There’s variables and more the script but, I did not include it since its big and messy.


Example of what am trying to achieve:
image

Help is really, really appreciated. :happy1:

Your script is making a new intvalue every single time it touches which could lead to very big problems, I would reccomend adding the intvalue to the character as soon as its created either through startercharacterscripts or some characteradded event
I would then only set the value of the multiplier depending on what theyve touched

2 Likes

Hey @PapaBreadd, thanks for pointing that out. I’ll fix that now.