Activating Proximity Prompt with script not working

Hello, i have this issue where if i mine my tree it does spawn a log but my script wont activate the proximity prompt to collect it.
anybody got a idea why?
here is my code:

local label = script.Parent.Health
local treeStem = script.Parent
local swingsLeft = 10

local function onTouch(otherPart)
	local tool = otherPart.Parent
	if tool:IsA('Tool') and tool.Hitting.Value == true then
	    swingsLeft -= 1
	    label.GreenHealth.Size = UDim2.new(swingsLeft/10, 0, 1, 0)
	end
	if swingsLeft <= 0 then
		if script.Parent.Parent:FindFirstChild("Leaves") then
			script.Parent.Parent.Leaves:Destroy()
			script.Parent.Parent.Leaves2:Destroy()
			script.Parent.Parent.Leaves3:Destroy()
			script.Parent.Parent.Leaves4:Destroy()
			script.Parent.Parent.Wood:Destroy()
			script.Parent.Parent.Wood2:Destroy()
			script.Parent.Parent.Wood3:Destroy()
			script.Parent.Parent.TreeStem:Destroy()
		end
		script.Parent.Health.Enabled = false
		if script.Parent.Parent.TreeStem2.ProximityPrompt.Enabled == true then
			script.Parent.Parent.TreeStem2.ProximityPrompt.Enabled = true
			
			
		end
	end
end

treeStem.Touched:Connect(onTouch)

here is a picture where all my stuff is parented and childed to:
image
anybody know the issue?

This is just keeping the proximity prompt enabled, change the == true to == false.

1 Like

still wont work. with the enablinjg

Workspace.Tree4.TreeStem.Script:22: attempt to index nil with ‘Health’
i do get this error.

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