Hello, I recently been trying to make a tree that can be cut down when the player is touching the trunk and their mousebutton1 is down. I made a localscript firing whenever the player clicks the mousebutton1down. I have made a script inside of trunk, the trunk of my tree. Here is the script:
script.Parent.Touched:Connect(function(hit) if hit.Parent.Humanoid ~= nil then game.ReplicatedStorage.RemoteEvents.Punch.OnServerEvent:Wait() script.Parent.Parent.BillboardGui.HealthString.Health.Value = script.Parent.Parent.BillboardGui.HealthString.Health.Value - 1 end end)
I am having issues with this script, and would be happy to find a good alternative if possible. The problem exactly is, the value named "Health," isn't changing when I touch it and click my MouseButton1.
Try:
if hit.Parent:FindFirstChild("Humanoid") then
on line 2
Oh wait, fixed it. The reason why it doesn't work was because the trunk was untouchable for some reason.