generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Can Someone Help me With My Scripts?

Previous Thread :: Next Thread 
war8989 is not online. war8989
Joined: 21 Feb 2009
Total Posts: 123
07 Mar 2012 08:31 PM
Ok I created a game where you cut down trees to get logs. So I created an axe tool and a tree model. My problem is I try to cut down the tree by hitting the tree with the axe tool multiple times and the tree doesn't fall down what is the problem? Here is my stuff in my place......

The Tree has the following in it:

Blocks : Model : Includes 13 Parts
Health : IntValue : = 10
$Configure : Script
Dead : BoolValue : = false
Log : IntValue : = 3
Bark : Part
DeadCheck : Script

Everything is a child of Tree except Blocks is a parent of 13 parts.

The Axe Tool has the following in it:
Animation : Script
Destroy : Script
Health : IntValue : = 20
Key : StringValue : = nil
Origin : Vector3Value : = 0,0,0
Target : ObjectValue : = nil
Local Gui : Script
Handle : Part
Script : Script

Script is a child of Handle, and everything else is a child of Wooden Axe.

Scripts:

$Configure:

---------------------------$Configure------------------------------
--- This makes sure the tree was configured correctly.
-------------------------------------------------------------------

tree = script.Parent
HP = tree.Health.Value
Log = tree.Log.Value

if HP == < 1 then
print("Tree's health is broken, removing tree...")
tree:Remove()
elseif Log == < 1 then
print("Tree's Log value is broken, removing tree...")
tree:Remove()
end


-- war8989

DeadCheck:

-----------------------------Dead Script--------------------------------------
-- This script kills the tree off if it is dead.
------------------------------------------------------------------------------

HP = script.Parent.Health.Value
Dead = script.Parent.Dead.Value
tree = script.Parent
BN = tree.Blocks:GetChildren()
SRegen = false

while true do
if HP == 0 and Dead == false then
print("Tree wasn't properly defeated, fixing...")
Dead = true
elseif HP == 0 and Dead == true then -- Finally if everything is how it's suppose to be then...
print("Tree was defeated correctly, killing and regening...")
for i = 1, #BN do
BN[i].Anchored = false
SRegen = true
end
if SRegen == true then
wait(180) -- Wait 3 Minutes
tree:clone().Parent = game.Workspace
tree.Blocks:MakeJoints()
SRegen = false
end
end
end

Animation Script:

Tool = script.Parent

function hit()
local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Slash"
anim.Parent = Tool
end
function onActivated()
if not Tool.Enabled then
return
end

Tool.Enabled = false
hit()
Tool.Enabled = true
end

Tool.Activated:connect(onActivated)

Destroy:

--------------------------------------------
-- Destroys the Tool if the Health is 0.
--------------------------------------------
Tool = script.Parent

if Tool.Heatlh.Value == 0 then
Tool:remove()
end

Local Gui:

local Tool = script.Parent;

function onKeyDown(key)
Tool.Key.Value = Tool.Key.Value .. key
end

go = false
function onEquippedLocal(mouse)
if mouse == nil then
print("Mouse not found")
return
end

mouse.Icon = "rbxasset://textures\\GunCursor.png"

Tool.Handle.BrickColor = game.Players:FindFirstChild(Tool.Parent.Name).TeamColor

Tool.Key.Value = ""
mouse.KeyDown:connect(onKeyDown)

go = true
while go do
wait(0.02)
Tool.Target.Value = mouse.Target
Tool.Origin.Value = mouse.Origin.p
end
end

function onUnequippedLocal(mouse)
go = false
wait(0.05)
Tool.Target.Value = nil
Tool.Origin.Value = Vector3.new(0, 0, 0)
end

Tool.Equipped:connect(onEquippedLocal)
Tool.Unequipped:connect(onUnequippedLocal)

Script inside Handle:

Tool = script.Parent
ting = 0
function onTouched(hit)
if ting == 0 then
ting = 1
if hit.Parent.Name == "Tree" then
user = game.Players:findFirstChild(Tool.Parent.Name) -- Find the Player who hit the tree with the axe.

hit.Parent.Health.Value = hit.Parent.Health.Value - 8

if hit.Parent.Health.Value == < 1 and hit.Parent.Dead.Value == false then --Check if the tree was already destroyed.
-- This is where to add Logs
hit.Parent.Dead.Value = true -- This makes the tree destroyed.
script.Parent.Parent.Health.Value = script.Parent.Parent.Health.Value - 4
else
wait(1)
end
end
ting = 0
end
end
connection = Tool.Handle.Touched:connect(onTouched)
Report Abuse
dirk29 is not online. dirk29
Joined: 26 May 2010
Total Posts: 1142
07 Mar 2012 09:03 PM
Find the output and tell us whats wrong or not running.
Report Abuse
war8989 is not online. war8989
Joined: 21 Feb 2009
Total Posts: 123
07 Mar 2012 09:12 PM
The problem is when I run it the game says it's not responding.
Report Abuse
TheNewFissy is not online. TheNewFissy
Joined: 03 Jan 2011
Total Posts: 1301
07 Mar 2012 09:35 PM
-----------------------------Dead Script--------------------------------------
-- This script kills the tree off if it is dead.
------------------------------------------------------------------------------

HP = script.Parent.Health.Value
Dead = script.Parent.Dead.Value
tree = script.Parent
BN = tree.Blocks:GetChildren()
SRegen = false

while true do
wait()
if HP == 0 and Dead == false then
print("Tree wasn't properly defeated, fixing...")
Dead = true
elseif HP == 0 and Dead == true then -- Finally if everything is how it's suppose to be then...
print("Tree was defeated correctly, killing and regening...")
for i = 1, #BN do
BN[i].Anchored = false
SRegen = true
end
if SRegen == true then
wait(180) -- Wait 3 Minutes
tree:clone().Parent = game.Workspace
tree.Blocks:MakeJoints()
SRegen = false
end
end
end
Report Abuse
war8989 is not online. war8989
Joined: 21 Feb 2009
Total Posts: 123
07 Mar 2012 10:27 PM
Doesn't work I need more help!
Report Abuse
0123Red is not online. 0123Red
Joined: 27 Feb 2010
Total Posts: 268
07 Mar 2012 11:58 PM
Got it, after the first
while true do

on the next line make sure to add a small

wait()

the reason it was breaking is because the while true do loop with no wait is forever with no stopping it
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image