Not Detecting Property Changed Signal

:sob: any changes made on the client won’t replicate to the server unless you explicitly do it by using a RemoteEvent.

Those are the only two scripts

We’ve already gone over this the current problem is that the XP value he had in the playeradded function isnt showing up in the player for some odd reason

If those are the only two scripts then I honestly have no idea whats making it not be there, was it doing this before?

Before you gave your script, it was in there just fine. I’m unsure on what the issue is-

Okay can you put your client script and then you server script seperately in two different code sections please

-- Services
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")

local plr = game.Players.PlayerAdded:Wait()
-- DataStore
local XPDataStore = DataStoreService:GetDataStore("StoreXP")


local Value = 0


Players.PlayerAdded:Connect(function(player)

	local xpCount = Instance.new("IntValue")
	xpCount.Name = "XP_Count"
	xpCount.Value = 0 
	xpCount.Parent = player

	xpCount:GetPropertyChangedSignal("Value"):Connect(function(newVal)
		print("New XP value:", newVal)
	end)


end)

game.Players.PlayerAdded:Connect(function(player)
	-----------------------------------------------------------
	local xp= player:WaitForChild("XP_Count")

	xp.Parent = player
	xp.Value = 0 
	xp.Value = XPDataStore:GetAsync(player.UserId) or Value
	XPDataStore:SetAsync(player.UserId, xp.Value)
	-----------------------------------------------------------

	------------------------------------------------------------
	game.Players.PlayerRemoving:Connect(function(player)
		XPDataStore:SetAsync(player.UserId, player["XP_Count"].Value)

	end)

end) 

local RemoteEvent = game.ReplicatedStorage.RemoteEvent

RemoteEvent.OnServerEvent:Connect(function(player)
	local xp = player:WaitForChild("XP_Count")
	xp.Value += 1
end)

local tool = script.Parent 

local RemoteEvent = game.ReplicatedStorage.RemoteEvent

tool.Activated:Connect(function()
	local player = game.Players:GetPlayerFromCharacter(tool.Parent)
	if player then
		RemoteEvent:FireServer()
	end
end)



Try this new server script

-- Services
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")

-- DataStore
local XPDataStore = DataStoreService:GetDataStore("StoreXP")

local Value = 0


Players.PlayerAdded:Connect(function(player)

	local xpCount = Instance.new("IntValue")
	xpCount.Name = "XP_Count"
	xpCount.Value = 0 
	xpCount.Parent = player

	xpCount:GetPropertyChangedSignal("Value"):Connect(function(newVal)
		print("New XP value:", newVal)
	end)


end)

game.Players.PlayerAdded:Connect(function(player)
	-----------------------------------------------------------
	local xp= player:WaitForChild("XP_Count")

	xp.Parent = player
	xp.Value = 0 
	xp.Value = XPDataStore:GetAsync(player.UserId) or Value
	XPDataStore:SetAsync(player.UserId, xp.Value)
	-----------------------------------------------------------

	------------------------------------------------------------
	game.Players.PlayerRemoving:Connect(function(player)
		XPDataStore:SetAsync(player.UserId, player["XP_Count"].Value)

	end)

end) 

local RemoteEvent = game.ReplicatedStorage.RemoteEvent

RemoteEvent.OnServerEvent:Connect(function(player)
	local xp = player:WaitForChild("XP_Count")
	xp.Value += 1
end)
1 Like

It works now, thank you. What was the cause of it not showing up?

1 Like

It’s because at the top you had a PlayerAdded:Wait() which just probably yielded the whole entire script thus not allowing the player added function to be registered and then when its not registered then when a player joins it wouldnt give them the XP value in their player

pattinson-smile

1 Like

Well, thank you so much for your help. I’ll definitely keep that in mind for any other things I decide to script.

1 Like

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