Trying to make this script + 1 to an int value stored on the player that hit the rock. This is the rocks script at the moment. I have set up an inventory folder on the player but every time I thought of a way to add to the int value it couldnt find the folder

local StoneOre = script.Parent
local label = StoneOre.Health
local OreLocations = game.Workspace.Mines.MineOne.OreLocations:GetChildren()
local HitsLeft = 10



local function onTouch(otherPart)
	local tool = otherPart.Parent
	local player = otherPart.Parent.Parent
	if tool:IsA('Tool') and tool.Mining.Value == true then
		HitsLeft -= 1
		label.Green.Size = UDim2.new(HitsLeft/10, 0, 1, 0)
		print("Rock Hit")
	end
	if HitsLeft<= 0 then
		local currentPos = StoneOre.Position
		local currentPlace = nil
		for _, place in pairs(OreLocations) do
			if currentPos == place.Position then
				currentPlace = place
				break
			end
		end
		for _, place in pairs(OreLocations) do
			if place.Free.Value == true then
				StoneOre.Position = place.Position
				place.Free.Value = false
				break
			end
		end
		if currentPlace then
				currentPlace.Free.Value = true
		end
		HitsLeft = 10
		label.Green.Size = UDim2.new(1, 0, 1, 0)
	end
end
StoneOre.Touched:Connect(onTouch)

2 comments

0

Where is this script located?

0

workspace > mines > ores > stone attached to the stone