NumberValue not updating at all (solved)

I tried to make this barrier spawns near the player, however the value isn’t updating anytime

i searched through several threads and tried to put the value inside the loop, it still spawns the barrier on a fixed place

heres the code for the spawning

game.Players.PlayerAdded:Connect(function(player)
	local enabled = false
	game.ReplicatedStorage.ToggleBarrier.OnServerEvent:Connect(function()
		if not enabled then
			enabled = true
			while wait(0.4) do
				if enabled then
				local offset = script.Offset
		local Character = player.Character.HumanoidRootPart
	local NewPart = game.ServerStorage.Barrier
	local barrier = NewPart:Clone()
					barrier.Position = Vector3.new(offset.Value, 16.5, -5998.6) + Vector3.new(math.floor(math.random(-2,2)*20),0,0)
		barrier.Parent = workspace
	game.Debris:AddItem(barrier, 5)
					game.ReplicatedStorage.Barriermove:FireAllClients(player,barrier)
				else
					break
				end
			end
		else
			enabled = false
end
	end)
end)

you should check if you have changed the offset value or not, or if there are any mistakes in your code of changing the value of the offset value

a simple code of changing is like this:

script.Offset.Value = 3

Changed the code, now it uses value inside script but still not changing where the barriers spawn

local offset = -62.175
game.Players.PlayerAdded:Connect(function(player)
	local enabled = false
	game.ReplicatedStorage.ToggleBarrier.OnServerEvent:Connect(function()
		if not enabled then
			enabled = true
			while wait(0.4) do
				if enabled then
		local Character = player.Character.HumanoidRootPart
	local NewPart = game.ServerStorage.Barrier
	local barrier = NewPart:Clone()
					barrier.Position = Vector3.new(offset, 16.5, -5998.6) + Vector3.new(math.floor(math.random(-2,2)*20),0,0)
		barrier.Parent = workspace
	game.Debris:AddItem(barrier, 5)
					game.ReplicatedStorage.Barriermove:FireAllClients(player,barrier)
				else
					break
				end
			end
		else
			enabled = false
end
	end)
end)

game.ReplicatedStorage.Add1.OnServerEvent:Connect(function()
	offset += 20
	print(offset)
end)


game.ReplicatedStorage.Negate1.OnServerEvent:Connect(function()
	offset = 20
	print(offset)
end)

it still spawns on a fixed point

Wait it was just me whos silly enough and not update the value on a serverscript, thanks for the help tho, i appreciate it

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