Ad
Log in to vote
0

Whats the best way to make choppable trees?

Asked by 11 days ago
Edited 11 days ago

I have been working on this one thing for a few months now but every time i have 1 issue that is ruining the hole script. I'm trying to make a choppable tree. With the current script i cant copy the tree to make a forest.

Here is a link of a video, thats how i want the trees to work.

http://www.youtube.com/watch?v=NhNmJcKMpvs

This in the script that I have now, It works with a remote event: the unachoring of the parts is in the script, the GUI is via the remote event to the players localscript. It would be great if someone will take the time to help me with this.

--==========================script ( inside of the tree) =================

local RemoteEvent = Instance.new("RemoteEvent")
local RemoteEvent = Instance.new("RemoteEvent");
RemoteEvent.Parent = game:GetService("ReplicatedStorage");

local click = script.Parent:WaitForChild("ClickDetector")

click.MouseClick:Connect (function(player)
    RemoteEvent:FireClient(player)
    wait(3.5)
    for _,v in pairs (script.Parent.Parent.Leaves:GetChildren()) do
    if v:IsA("Part") then--Checks if the Child that is inside the Model is ClassName Part.
    v.Anchored = false
    end
end
    for _,v in pairs (script.Parent.Parent.Logs:GetChildren()) do
    if v:IsA("Part") then--Checks if the Child that is inside the Model is ClassName Part.
    v.Anchored = false
    end
end
   script.Parent.Parent.Wood:Destroy()

end)

--============Localscript==============

wait(2)
local RemoteEvent = Instance.new("RemoteEvent")
RemoteEvent.Parent = game:GetService("ReplicatedStorage")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local char = plr.Character
local x = script:FindFirstChild("Wood")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)



local GetWood = true

function ShowProgress(tree)
    if tree == 'SmallTree1' then
        for i = 0,1,.01 do
            WC.BG.Progress.Size = UDim2.new(i,0,1,0)
            wait()
        end
    elseif tree == 'MediumTree' then
        for i = 0,1,.005 do
            WC.BG.Progress.Size = UDim2.new(i,0,1,0)
            wait()
        end
    end
end

local function RemoteSmall()
    GetWood = false
    WC = plr.PlayerGui.WoodChopper
    WC.BG.Visible = true
    char.Humanoid.WalkSpeed = 0
    char.Humanoid.JumpPower = 0
    animation:Play()
    ShowProgress('SmallTree1')
    animation:Stop()
    char.Humanoid.WalkSpeed = 16
    char.Humanoid.JumpPower = 50
    WC.BG.Visible = false
end


RemoteEvent.OnClientEvent:Connect(RemoteSmall)
0
you don't have a variable for GetWood. AnotherPerson_999 1 — 11d
0
Thats not the problem, The problem is that i cant copy the tree Alwaysrube 13 — 11d

Answer this question