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 » Scripters
Home Search
 

Re: My script isn't going to elseif!?

Previous Thread :: Next Thread 
Lithileix is not online. 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
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
11 Sep 2016 04:19 PM
tldr
Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
11 Sep 2016 04:24 PM
tldr [2]
Report Abuse
Lithileix is not online. 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 is not online. Lithileix
Joined: 09 Aug 2016
Total Posts: 111
11 Sep 2016 06:54 PM
bump
Report Abuse
Lithileix is not online. Lithileix
Joined: 09 Aug 2016
Total Posts: 111
11 Sep 2016 07:32 PM
bump
Report Abuse
Fluffy_Husky is not online. Fluffy_Husky
Joined: 23 May 2016
Total Posts: 763
11 Sep 2016 07:33 PM
literally dont see any elseif in the last post
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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