Mario inspired block

Hello, i would like to know how to code something that has been annoying for me to code, Basically i have a custom StarterCharacter with a “CollisionUp” part on top of the head. I have made a script in a block but i can’t figure out what to write next. I wanted to make it that if the part touches the block then it changes color ONLY for the local player, and gives a coin to him

local player = game.Players.LocalPlayer

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then

	end
end)

Also im just a beginner

Is the coin an integer value that affects the gameplay?

Yes, its a leaderstats value from server script service

OK.

local ClaimedClient: RemoteEvent? = game:GetService("ReplicatedStorage").Network.ClaimC
local CS = game:GetService("CollectionService")
local Block:BasePart? = script.Parent
Block.Touched:Connect(function(Hit)
	local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
	if Player ~= nil and Player.Character:FindFirstChildOfClass("Humanoid").Health > 0 and Player.Character.CollideUp then
		if not CS:HasTag(Block, Player.Name) then
			CS:AddTag(Block, Player.Name)
			Player.leaderstats.Coins.Value += 1
			ClaimedClient:FireClient(Player, Block)
		end
	end
end)
-- Client
ClaimedClient.OnClientEvent:Connect(function(Block:BasePart?)
	Block.Color = Color3.new(0.509804, 0.254902, 0.0745098)
end)

Will this work if i place multiple?

You would need to use collectionservice for that.

How should i use it? Sorry im not very experienced

local CS = game:GetService("CollectionService")

local Players = game:GetService("Players")

local ClaimedClient: RemoteEvent? = game:GetService("ReplicatedStorage").Network.ClaimC

local Connection = {}

function Touch(Block)
	Connection[Block] = {}
	local Touched = {}
	table.insert(Connection[Block], Block.Touched:Connect(function(Hit)
		local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
		if Player ~= nil and Player.Character:FindFirstChildOfClass("Humanoid").Health > 0 and Player.Character.CollideUp then
			if not CS:HasTag(Block, Player.Name) then
				CS:AddTag(Block, Player.Name)
				Player.leaderstats.Coins.Value += 1
				ClaimedClient:FireClient(Player, Block)
			end
		end
	end))
end

do
	local Tags = CS:GetTagged("HitBlock")
	for Timer=1, #Tags do
		local Part = Tags[Timer]
		Touch(Part)
	end
end

CS:GetInstanceAddedSignal("HitBlock"):Connect(Touch)

Apply HitBlock tag to every Block you want to be hit.

one thing: the devforums doesn’t want people to give whole scripts so I can’t do this sadly :frowning: