Not returning to function?
Well, it seems I never get it right when it comes to returning to functions, so I'd like for you, my friends, to help me remember this.
Basically what this script is, is a item equip script, for a horror game engine/framework I'm working on. When you hit F, the currently equipped light source should be welded too your arm.
I scripted the functions before the KeyDown event.
It doesn't seem to work, so I know I didn't recall the function right. Can anyone tell me what I'd done wrong?
Code:
01 | <pre class = "brush: lua" > repeat wait() until game.Players.LocalPlayer |
03 | UseableAmmo = { [ 1 ] = script.NumTorches, [ 2 ] = script.LanternOil, [ 3 ] = script.FlashlightBattery } |
05 | NumTorches = UseableAmmo [ 1 ] .Value |
06 | LanternOil = UseableAmmo [ 2 ] .Value |
07 | FlashlightBattery = UseableAmmo [ 3 ] .Value |
09 | Mouse = game.Players.LocalPlayer:GetMouse() |
11 | Torch = { "Torch" , NumTorches } |
12 | Lantern = { "Lantern" ,LanternOil } |
13 | Flashlight = { "Flashlight" , FlashlightBattery } |
14 | print "Usable Light sources defined" |
16 | function GetItemUsing() |
19 | print ( "Detected that your using " ..NowUsing) |
25 | if NumTorches.Value < 1 then |
29 | script.Error.RunOut.Visible = true |
30 | script.Error.RunOut:TweenPosition(UDim 2. new( 0.5 , 0 , 0.75 , 0 ), "Out" , "Quad" , 4 ) |
32 | script.Error.RunOut.TextTransparency = (script.Error.RunOut.TextTransparency + ( 60 / 4 )/ 10 ) |
34 | script.Error.RunOut.Visible = false |
35 | script.Error.RunOut.TextTransparency = 0 |
36 | script.Error.RunOut.Position = UDim 2. new( 0.5 , 0 , 0.85 , 0 ) |
38 | elseif NumTorches > 1 then |
39 | if Ocupied = = false then |
40 | if NowUsing = = "None" then |
41 | print "Nothing to equip" |
43 | script.Error.RunOut.Visible = true |
44 | script.Error.RunOut:TweenPosition(UDim 2. new( 0.5 , 0 , 0.75 , 0 ), "Out" , "Quad" , 4 ) |
46 | script.Error.RunOut.TextTransparency = (script.Error.RunOut.TextTransparency + ( 60 / 4 )/ 10 ) |
48 | script.Error.RunOut.Visible = false |
49 | script.Error.RunOut.TextTransparency = 0 |
50 | script.Error.RunOut.Position = UDim 2. new( 0.5 , 0 , 0.85 , 0 ) |
52 | elseif NowUsing = = "Torch" then |
53 | TorchW = Instance.new( "Weld" ) |
54 | TorchW.Part 0 = game.Players.LocalPlayer.Character.Torso |
55 | TorchMod = game.ReplicatedStorage.TorchModel:clone() |
56 | TorchW.Part 1 = TorchMod |
57 | TorchW.Parent = TorchMod.Arm |
58 | TorchW.C 0 = CFrame.new(- 1 , 0 , 0 )*CFrame.fromEulerAnglesXYZ( 0 , 0 , 0 ) |
67 | local KeyPressed = Key:lower() |
68 | if KeyPressed = = "f" then |
69 | if ItemEquipped = = false then |
75 | Mouse.KeyDown:connect(KeyDown) |