Issues with Cloning and Stats Display

I’m not using UI to detect a player clicking

Also this is my serverscript version of the cloning except it gives no errors at all but still doesn’t work

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		
		headFolder = Instance.new("Folder")
		headFolder.Name = "headContainer"
		headFolder.Parent = char
		
		head = char:WaitForChild("Head")
	end)
	
	local ContainerSpace = player:WaitForChild("Inventory").HoldingSpace

	UserInputService.InputBegan:Connect(function(input)


		local function clicked()
			h.Value += 1 * m.Value

			local cloned = head:Clone()

			cloned.Position = head.Position + Vector3.new(0, 1*h.Value, 0)
		end

		if h.Value < ContainerSpace.Value then 
			if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
				clicked()
			end
		end

	end)

end)

There are some functions that server scripts won’t even print or warn you about plus @TurtlesUnknown mentioned why you had userinputservice in the script. This can only be handled by the client. Telling from this situation, You might have to remake entire leader stats system again. stats can only be changed from the server as @Forummer said below. You should also use remote events for the selling and cloning stuff. Using only local scripts for this stuff isn’t the safest way.

Stats need to be changed on the server otherwise they won’t replicate to the server and therefore other clients.

2 Likes

So how I would I divide the script? Do I just fire a remote event when a player clicks then send that to a script that clones the parts?

Update on the situation:
I managed to follow what you guys have said and made it so when a player clicks, it fires an even and which then a serverscript executes the rest of the stuff.

Problem:

All Issues have been solved