Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Problem with glitching tools in my game tools glitch sometimes?

Asked by
gessettw -31
6 years ago
Edited 6 years ago

In my game main thing to do is cuting trees , all trees have amount of health , trees have normal script but tools have local script , when i make bigger tool it work sometimes like this : i cut 1 tree 2 , 3 ,4 and tool broke after it need press backspace to collect tool to work again sometools broke after 1 tree cut why ? im too have problem with fe when i enable fe trees wont fall (unanchor)

tools local script :Tool = script.Parent qwerty=true

function onActivated() if not Tool.Enabled then return end --Tool.Parent.Torso["Right Shoulder"].MaxVelocity = 0.6 --Tool.Parent.Torso["Right Shoulder"].DesiredAngle = -3.6

local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Slash"
anim.Parent = Tool

Tool.Enabled = false
wait(.2)
Tool.Enabled = true

end

function onTouched(hit) if qwerty==true then if hit.Parent.Name=="Tree" or hit.Parent.Name=="MTree" or hit.Parent.Name=="LTree" or hit.Parent.Name=="STree" then qwerty=false if hit.Parent.Hits.Value<= 0 then qwerty=true return end if hit.Parent.Name=="STree" and hit.Parent.Hits:FindFirstChild(script.Parent.Parent.Name)==nil then P=Instance.new("NumberValue") P.Name=script.Parent.Parent.Name P.Parent=hit.Parent.Hits end if hit.Parent.Name=="STree" then hit.Parent.Hits:FindFirstChild(script.Parent.Parent.Name).Value=hit.Parent.Hits:FindFirstChild(script.Parent.Parent.Name).Value+2 end hit.Parent.Hits.Value=hit.Parent.Hits.Value-2 p=game.Players:FindFirstChild(script.Parent.Parent.Name) if p ~=nil then p.PlayerGui.Text.Text.Text=hit.Parent.Hits.Value end if hit.Parent.Hits.Value<= 0 then p=game.Players:FindFirstChild(script.Parent.Parent.Name) if p ~=nil then if hit.Parent.Name=="Tree" then p.leaderstats:FindFirstChild("Logs").Value=p.leaderstats:FindFirstChild("Logs").Value+1 elseif hit.Parent.Name=="MTree" then p.leaderstats:FindFirstChild("Logs").Value=p.leaderstats:FindFirstChild("Logs").Value+3 elseif hit.Parent.Name=="LTree" then p.leaderstats:FindFirstChild("Logs").Value=p.leaderstats:FindFirstChild("Logs").Value+5 elseif hit.Parent.Name=="STree" then p.leaderstats:FindFirstChild("Logs").Value=math.ceil(p.leaderstats:FindFirstChild("Logs").Value+hit.Parent.Hits:FindFirstChild(script.Parent.Parent.Name).Value/12) Most=true Players=hit.Parent.Hits:GetChildren() for I=1,#Players do if Players[I]~=hit.Parent.Hits:FindFirstChild(script.Parent.Parent.Name) and Players[I].Value>hit.Parent.Hits:FindFirstChild(script.Parent.Parent.Name) then Most=false end end if Most==true then script.Parent.Award.Value=true end end end end wait(0.5) qwerty=true end end end

Tool.Activated:connect(onActivated) connection = Tool.Handle.Touched:connect(onTouched)

Tool = script.Parent qwerty=true

function onActivated() if not Tool.Enabled then return end --Tool.Parent.Torso["Right Shoulder"].MaxVelocity = 0.6 --Tool.Parent.Torso["Right Shoulder"].DesiredAngle = -3.6

local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Slash"
anim.Parent = Tool

Tool.Enabled = false
wait(.2)
Tool.Enabled = true

end

function onTouched(hit) if qwerty==true then if hit.Parent.Name=="Tree" or hit.Parent.Name=="MTree" or hit.Parent.Name=="LTree" or hit.Parent.Name=="STree" then qwerty=false if hit.Parent.Hits.Value<= 0 then qwerty=true return end if hit.Parent.Name=="STree" and hit.Parent.Hits:FindFirstChild(script.Parent.Parent.Name)==nil then P=Instance.new("NumberValue") P.Name=script.Parent.Parent.Name P.Parent=hit.Parent.Hits end if hit.Parent.Name=="STree" then hit.Parent.Hits:FindFirstChild(script.Parent.Parent.Name).Value=hit.Parent.Hits:FindFirstChild(script.Parent.Parent.Name).Value+2 end hit.Parent.Hits.Value=hit.Parent.Hits.Value-2 p=game.Players:FindFirstChild(script.Parent.Parent.Name) if p ~=nil then p.PlayerGui.Text.Text.Text=hit.Parent.Hits.Value end if hit.Parent.Hits.Value<= 0 then p=game.Players:FindFirstChild(script.Parent.Parent.Name) if p ~=nil then if hit.Parent.Name=="Tree" then p.leaderstats:FindFirstChild("Logs").Value=p.leaderstats:FindFirstChild("Logs").Value+1 elseif hit.Parent.Name=="MTree" then p.leaderstats:FindFirstChild("Logs").Value=p.leaderstats:FindFirstChild("Logs").Value+3 elseif hit.Parent.Name=="LTree" then p.leaderstats:FindFirstChild("Logs").Value=p.leaderstats:FindFirstChild("Logs").Value+5 elseif hit.Parent.Name=="STree" then p.leaderstats:FindFirstChild("Logs").Value=math.ceil(p.leaderstats:FindFirstChild("Logs").Value+hit.Parent.Hits:FindFirstChild(script.Parent.Parent.Name).Value/12) Most=true Players=hit.Parent.Hits:GetChildren() for I=1,#Players do if Players[I]~=hit.Parent.Hits:FindFirstChild(script.Parent.Parent.Name) and Players[I].Value>hit.Parent.Hits:FindFirstChild(script.Parent.Parent.Name) then Most=false end end if Most==true then script.Parent.Award.Value=true end end end end wait(0.5) qwerty=true end end end

Tool.Activated:connect(onActivated) connection = Tool.Handle.Touched:connect(onTouched)

trees script : hits = script.Parent.Hits b=script.Parent:clone() qwerty=false function OnChange() if qwerty==false then if hits.Value<=0 then hits.Value=0 qwerty=true c=script.Parent:GetChildren() for i=1, #c do if c[i].Name=="Tree" then c[i].Anchored=false local number = math.random(1, 2) if number == 1 then c[i].Velocity = c[i].CFrame.lookVector * math.random(-20, -10) end if number == 2 then c[i].Velocity = c[i].CFrame.lookVector * math.random(10, 20) end end end wait(85) script.Parent:remove() w = b:clone() w.Parent=game.Workspace.LeTrees w:MakeJoints() connection:disconnect() end end end connection=script.Parent.Hits.Changed:connect(OnChange)

1
You **are** kidding, right? How the hell are we meant to fix your code if you don't give us the code? CyroStorms 4 — 6y
0
tools script or tree ? gessettw -31 — 6y
0
i add now code ok ? gessettw -31 — 6y
0
pls gessettw -31 — 6y
View all comments (2 more)
0
Can you please put this in a code block? Prestory 1395 — 6y
0
you think i need put tool script to tree parts ? gessettw -31 — 6y

Answer this question