Change in IntValue Not Detected?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear! i want my local script to detect a change in the intvalue within my car, the intvalue is changed by a server script

  2. What is the issue? Include screenshots / videos if possible! It isnt being detected

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked everywhere noone has the specific problem i have
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Server script that clones the car and after 5 seconds, changes the cars intvalue

local replicatedstorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local random = math.random(1,5)
Players.PlayerAdded:Connect(function(player)
	wait(random)
	print(random)
	print(player.Name .. " joined the game!")
	local car = replicatedstorage.CAR1
	local cone = car:Clone()
	cone.Parent = game.Workspace
	for i,v in pairs(workspace["MAP BEACH"]:GetChildren()) do
		if v:IsA("Part") then
			if v:FindFirstChildWhichIsA("BoolValue")then
				if v.Value.Value == false then
					v.Value.Value = true
					cone:PivotTo(v.CFrame)
				end
			end
		end
	end
	wait(2)
	cone.Chassis.DriveSeat:Sit(player.Character.Humanoid)
	player.Character.Humanoid.JumpHeight = 0
	cone.Chassis.Owner.Value = player.Name
	cone.Chassis.Health.Value = 100000000
	wait(5)
	cone.Chassis.Health.Value = 2
end)

local script:

wait(7)
local car = nil
local Players = game:GetService("Players")
local player = Players.LocalPlayer
for i,v in pairs(game.Workspace:GetChildren()) do
	if v:IsA("Model")then
		if v:FindFirstChild("Chassis") then
			if v.Chassis.Owner.Value == player.Name then
				car = v.Chassis
			end
		end
	end
end

local function healthchanger()
	local gui = game:GetService("StarterGui").ScreenGui.Frame.HELTH
	car.Health.Value = tostring(gui.Text)
end

car.Health:GetPropertyChangedSignal("Value"):Connect(healthchanger)
wait(5)
print(car.Health.Value)

IF YOU HAVE ANY QUESTIONS ABOUT THE SCRIPT PLEASE QUOTE IT AND ASK ME :slight_smile:
output:
image

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

also for some reason it keeps changing to 100 for localscript im not sure why

Why dont you just do a RemoteEvent to tell the client when the value has changed?

I’ve noticed in the code you set the value to value.value, this will cause an issue because the server is constantly trying to find “Value”, and if they dont find it they will ignore it.

Also, use GetDescendants(), it will find every single object inside of the model, not just the first.

Is it possible that your value is stored inside of one of the models?

local function healthchanger(health)
	--Do something with 'health'.
end

car.Health.Changed:Connect(healthchanger)

You’re also modifying the ‘StarterGui’ container when you should be modifying the local player’s ‘PlayerGui’ container instead.

1 Like

could you please tell me where i cant find it - quote it please

that is a possibility and i will use it if i have to but i also want to know why the simple way wont work