Lithileix
|
  |
| Joined: 09 Aug 2016 |
| Total Posts: 111 |
|
|
| 11 Sep 2016 04:15 PM |
Okay, so here's my issue.
I modified a copy tool to only copy specific parts when there's enough resources and to cost resources. It works, but for ONE part. For some reasons, the "elseif" statements for my V##p##t and my Tesla Motor part don't work even though the V12 works. It throws no errors so I have no idea what code to highlight.
debounce = false local vPlayer = game.Players.LocalPlayer local SBox = Instance.new("SelectionBox") local Tool = script.Parent;
local Select local Orig local Dragger mouse = game.Players.LocalPlayer:GetMouse() function onButton1Down(mouse)
local Target = mouse.Target local Sound = Instance.new("Sound")-- The "ding" sound Sound.SoundId = "rbxasset://sounds\\electronicpingshort.wav" Sound.Name = "PewPew" Sound.Parent = Tool
if Target and Target:IsA("BasePart") and not Target.Locked and Target.Name == "Engine" and Target.engineType.Value == "V12" and game.ReplicatedStorage.engine.Value >= 10 then print("PICKING ENGINE!") if debounce == false then game.ReplicatedStorage.engine.Value = game.ReplicatedStorage.engine.Value - 10 debounce = true Orig = Target Select = Orig:clone()
Select.Parent = game.Workspace Select.Position = Orig.Position + Vector3.new(0, 0.4, 0)
Dragger = Instance.new("Dragger") pcall(function() Dragger:MouseDown(Select, Vector3.new(0, 0, 0), {Select}) end)
SBox.Adornee = Select Sound:Play() wait(1.5)-- Edit this to how long you would like to wait until the next copy mouse.Icon = "rbxasset://textures\\DragCursor.png" debounce = false end elseif Target and Target:IsA("BasePart") and not Target.Locked and Target.Name == "Engine" and Target.engineType.Value == "V6" and game.ReplicatedStorage.engine.Value >= 5 then print("PICKING ENGINE!") if debounce == false then game.ReplicatedStorage.engine.Value = game.ReplicatedStorage.engine.Value - 5 debounce = true Orig = Target Select = Orig:clone()
Select.Parent = game.Workspace Select.Position = Orig.Position + Vector3.new(0, 0.4, 0)
Dragger = Instance.new("Dragger") pcall(function() Dragger:MouseDown(Select, Vector3.new(0, 0, 0), {Select}) end)
SBox.Adornee = Select Sound:Play() wait(1.5)-- Edit this to how long you would like to wait until the next copy mouse.Icon = "rbxasset://textures\\DragCursor.png" debounce = false end elseif Target and Target:IsA("BasePart") and not Target.Locked and Target.Name == "Engine" and Target.engineType.Value == "Tesla Engine" and game.ReplicatedStorage.metal.Value >= 15 then print("PICKING ENGINE!") if debounce == false then game.ReplicatedStorage.metal.Value = game.ReplicatedStorage.metal.Value - 15 debounce = true Orig = Target Select = Orig:clone()
Select.Parent = game.Workspace Select.Position = Orig.Position + Vector3.new(0, 0.4, 0)
Dragger = Instance.new("Dragger") pcall(function() Dragger:MouseDown(Select, Vector3.new(0, 0, 0), {Select}) end)
SBox.Adornee = Select Sound:Play() wait(1.5)-- Edit this to how long you would like to wait until the next copy mouse.Icon = "rbxasset://textures\\DragCursor.png" debounce = false end elseif Target and Target:IsA("BasePart") and not Target.Locked and Target.Name == "Engine" and Target.engineType.Value == "V6" and game.ReplicatedStorage.engine.Value < 5 then print("Not enough resources") elseif Target and Target:IsA("BasePart") and not Target.Locked and Target.Name == "Engine" and Target.engineType.Value == "V12" and game.ReplicatedStorage.engine.Value < 10 then print("Not enough resources") elseif Target and Target:IsA("BasePart") and not Target.Locked and Target.Name == "Engine" and Target.engineType.Value == "Tesla Motor" and game.ReplicatedStorage.metal.Value < 15 then print("Not enough resources") end end function onButton1Up(mouse) if Dragger then Orig = nil ############################################################################################################################################################# end end
function onMouseMove(mouse) if Dragger then mouse.Icon = "rbxasset://textures\\GrabRotateCursor.png" pcall(function() Dragger:MouseMove(mouse.UnitRay) end) else local Target = mouse.Target if Target and Target:IsA("BasePart") and not Target.Locked then mouse.Icon = "rbxasset://textures\\CloneOverCursor.png" else mouse.Icon = "rbxasset://textures\\CloneCursor.png" end end end
function onKeyDown(key) if Dragger then key = key:lower() if key == 'r' then Dragger:AxisRotate(Enum.Axis.Y) elseif key == 't' then Dragger:AxisRotate(Enum.Axis.Z) end end end
function onEquippedLocal(mouse) SBox.Color = BrickColor.new("Cyan") SBox.Parent = vPlayer.PlayerGui
mouse.Button1Down:connect(function() onButton1Down(mouse) end) mouse.Button1Up:connect(function() onButton1Up(mouse) end) mouse.Move:connect(function() onMouseMove(mouse) end) mouse.KeyDown:connect(onKeyDown) end
function onUnequippedLocal(mouse) if Tool:findFirstChild("PewPew") then Tool.PewPew:remove() end if Dragger then Orig = nil pcall(function() Dragger:MouseUp() end) Select = nil SBox.Adornee = nil Dragger = nil end end
Tool.Equipped:connect(onEquippedLocal) Tool.Unequipped:connect(onUnequippedLocal) |
|
|
| Report Abuse |
|
|
| |
|
JoshRBX
|
  |
| Joined: 19 May 2012 |
| Total Posts: 8778 |
|
| |
|
Lithileix
|
  |
| Joined: 09 Aug 2016 |
| Total Posts: 111 |
|
|
| 11 Sep 2016 04:47 PM |
TL;DR version nothing happens after this including elseif
if Target and Target:IsA("BasePart") and not Target.Locked and Target.Name == "Engine" and Target.engineType.Value == "V12" and game.ReplicatedStorage.engine.Value >= 10 then print("PICKING ENGINE!") if debounce == false then game.ReplicatedStorage.engine.Value = game.ReplicatedStorage.engine.Value - 10 debounce = true Orig = Target Select = Orig:clone()
Select.Parent = game.Workspace Select.Position = Orig.Position + Vector3.new(0, 0.4, 0)
Dragger = Instance.new("Dragger") pcall(function() Dragger:MouseDown(Select, Vector3.new(0, 0, 0), {Select}) end)
SBox.Adornee = Select Sound:Play() wait(1.5)-- Edit this to how long you would like to wait until the next copy mouse.Icon = "rbxasset://textures\\DragCursor.png" debounce = false end |
|
|
| Report Abuse |
|
|
Lithileix
|
  |
| Joined: 09 Aug 2016 |
| Total Posts: 111 |
|
| |
|
Lithileix
|
  |
| Joined: 09 Aug 2016 |
| Total Posts: 111 |
|
| |
|
|
| 11 Sep 2016 07:33 PM |
| literally dont see any elseif in the last post |
|
|
| Report Abuse |
|
|