Something very very simple does not work. help pls

Ok so the problem is that the ServerScript can’t detect my NumberValue that is inside the player instance.

LocalScript:

-- This LocalScript gives every player a copy of the NumberValue stored under the player instance

local numberValue = game:GetService("ReplicatedStorage").NumberValue

numberValue.Parent = game.Players.LocalPlayer

ServerScript:

game.Players.PlayerAdded:Connect(function(player)
	print("Test1") -- Prints successfully
	local numberValue = player:WaitForChild("NumberValue") -- The code is stuck at this line because it cannot find the NumberValue inside the player instance
	print("Test2") -- Does not print
	print(numberValue.Value) -- Does not print
end)

Any idea how to fix it?

The server cannot access any changes made on the client side.

So if I gave every player a copy of the NumberValue through a ServerScript, would it work?

By using :Clone() , yes.
cha cha cha

1 Like

Yes, try this server script:

local numberValue = game:GetService("ReplicatedStorage").NumberValue

game.Players.PlayerAdded:Connect(function(player)
	print("Test1") -- Prints successfully
    numberValue:Clone().Parent = player
	local numberValue = player:WaitForChild("NumberValue") -- The code is stuck at this line because it cannot find the NumberValue inside the player instance
	print("Test2") -- Does not print
	print(numberValue.Value) -- Does not print
end)
1 Like

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