Trying to make it so it detects when the XP value changes. I’ve tried doing xpValue.Value, didn’t work. I’ve tried xpValue.Changed as well. Unsure what to do.
xpValue:GetPropertyChangedSignal("Value"):Connect(function(newVal)
print("New XP value.")
end)
Okay your saying the value is changed through a local script, there either two things that means your either changing the value on the client without a remote event or your using as remote event to fire to the server that you want to change the XP and then it changes the XP
so if its not working then im going to guess your trying to do it with the former, but you havent showed any client code so we cant know that for sure
tool.Activated:Connect(function()
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
if player then
local xp = player:FindFirstChild("XP_Count")
xp.Value = xp.Value + 1
end
end)
Yeah well thats why it isnt working you can’t just reference the players XP_Count from the client and then expect it to change and replicate to the server you need to fire a remote event and then have the server script handler handle changing the XP for the player
-- Client Script
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
tool.Activated:Connect(function()
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
if player then
RemoteEvent:FireServer()
end
end)
-- Server Script
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
RemoteEvent.OnServerEvent:Connect(function(player)
player:FindFirstChild("XP_Count").Value += 1
end)