StackEnd
|
  |
| Joined: 20 Oct 2008 |
| Total Posts: 672 |
|
|
| 04 Mar 2014 03:34 PM |
So I'm making a tool. This script is inside the tool. When I play solo, the first ability (the only one created so far) it works. However, when I try to play in online mode, the equipping animation where your hand moves up plays twice before the animation finishes and pressing Q and E will not cycle moves. It's just over-all extremely buggy and I see nothing that could be wrong after staring at this script for the past hour. Help?
--Sound IDs local BlastSoundID = "http://www.roblox.com/asset/?id=2248511"
--Main variables local tool = script.Parent local selected = false local gotchar = false local active = false local mode = 0
--Predefined variables local larm local rarm local char local torso local player local gui local keydown local rweld local motors
--Fix joints function FixJoints() for _,v in pairs(torso:GetChildren()) do if v:IsA("Weld") or v:IsA("Motor6D") then v:destroy() end end for _,v in pairs(motors:GetChildren()) do v.Parent = torso end motors:destroy() end
--Equipped event tool.Equipped:connect(function(mouse) if selected == false then selected = true if gotchar == false then gotchar = true char = tool.Parent torso = char.Torso larm = char["Left Arm"] rarm = char["Right Arm"] player = game.Players:GetPlayerFromCharacter(char) end motors = Instance.new("Model") for _,v in pairs(torso:GetChildren()) do if v:IsA("Motor6D") then v:clone().Parent = motors end end rweld = Instance.new("Weld",torso) rweld.Part0 = torso rweld.Part1 = rarm rweld.C1 = CFrame.new(0,.5,0) rweld.C0 = CFrame.new(1.5,.5,0) coroutine.resume(coroutine.create(function() for i = 0, math.rad(90), .2 do rweld.C0 = rweld.C0 * CFrame.Angles(.2,0,0) wait() end end)) mode = 1 gui = Instance.new("ScreenGui") label = Instance.new("TextLabel",gui) label.BackgroundTransparency = 1 label.BorderSizePixel = 0 label.Size = UDim2.new(1,0,.1,0) label.Font = "Arial" label.FontSize = "Size36" label.Text = "Arcane Blast" gui.Parent = player.PlayerGui --Connect KeyDown event keydown = mouse.KeyDown:connect(function(key) if key == "e" then if mode < 3 then mode = mode + 1 else mode = 1 end elseif key == "q" then if mode > 1 then mode = mode - 1 else mode = 3 end end if mode == 1 then label.Text = "Arcane Blast" elseif mode == 2 then label.Text = "Shockwave" elseif mode == 3 then label.Text = "Magic Bolt" end end) end end)
--Activated event tool.Activated:connect(function() if active == false then if mode == 1 then active = true if torso:FindFirstChild("Left Shoulder") then char.Humanoid.WalkSpeed = 4 local motor = torso["Left Shoulder"] motor.Parent = nil local lweld = Instance.new("Weld",torso) lweld.Part0 = torso lweld.Part1 = larm lweld.C1 = CFrame.new(0,.5,0) lweld.C0 = CFrame.new(-1.5,.5,0) for i = 0, math.rad(90), .15 do lweld.C0 = lweld.C0 * CFrame.Angles(.15,-.15,0) wait() end wait(0.5) local blastsound = Instance.new("Sound",torso) blastsound.SoundId = BlastSoundID blastsound.PlayOnRemove = true blastsound:destroy() Blast(torso.CFrame + (torso.CFrame.lookVector * 10)) for i = math.rad(145), 0, -.25 do lweld.C0 = lweld.C0 * CFrame.Angles(-.25,-.25/20,0) wait() end wait(0.5) lweld:destroy() motor.Parent = torso char.Humanoid.WalkSpeed = 16 end active = false elseif mode == 2 then active = true --do stuff active = false elseif mode == 3 then active = true --do stuff active = false end end end)
--Unequipped event tool.Unequipped:connect(function() if selected == true then
if char.Humanoid.Health > 0 then FixJoints() end gui:destroy() mode = 0 --Disconnect KeyDown event keydown:disconnect() selected = false end end)
--Blast effect function Blast(pos) local colors = { "Institutional white", "Light stone grey" } for i = 1, 3 do coroutine.resume(coroutine.create(function() local p = Instance.new("Part") p.Anchored = true p.CanCollide = false p.TopSurface = 0 p.BottomSurface = 0 p.FormFactor = "Custom" p.Size = Vector3.new(1,1,1) p.BrickColor = BrickColor.new(colors[math.random(1,#colors)]) local pos = pos p.CFrame = pos p.Parent = tool local tagged = false p.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if hit.Parent.Name ~= char.Name then if tagged == false then tagged = true hit.Parent.Torso.Velocity = torso.CFrame.lookVector * 100 hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - math.random(2,7) hit.Parent.Humanoid.WalkSpeed = 0 for i = 0, 16, 0.2 do hit.Parent.Humanoid.WalkSpeed = i wait() end end end end end) for i = 0, 1, 1/10 do p.Size = p.Size + Vector3.new(3/3,3/3,3/3) p.CFrame = pos * CFrame.fromEulerAnglesXYZ( math.random(1,math.pi*2), math.random(1,math.pi*2), math.random(1,math.pi*2) ) p.Transparency = i wait() end p:destroy() end)) end end
|
|
|
| Report Abuse |
|
KingJacko
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 3944 |
|
|
| 04 Mar 2014 03:36 PM |
| this might need to be in a local script |
|
|
| Report Abuse |
|
McGunz
|
  |
| Joined: 26 Dec 2011 |
| Total Posts: 759 |
|
|
| 04 Mar 2014 03:37 PM |
| lol. run it in a hopperbin tool with a local script xD |
|
|
| Report Abuse |
|
StackEnd
|
  |
| Joined: 20 Oct 2008 |
| Total Posts: 672 |
|
|
| 04 Mar 2014 03:38 PM |
Why would a localscript make a difference? It's essentially running the same code just client-side.
I can't put it in a hopperbin because the code is designed for a Tool. |
|
|
| Report Abuse |
|
Vexedly
|
  |
| Joined: 15 Sep 2006 |
| Total Posts: 7011 |
|
| |
StackEnd
|
  |
| Joined: 20 Oct 2008 |
| Total Posts: 672 |
|
|
| 04 Mar 2014 03:40 PM |
| I've never heard this. I have several tools that run with regular scripts. Source? |
|
|
| Report Abuse |
|
StackEnd
|
  |
| Joined: 20 Oct 2008 |
| Total Posts: 672 |
|
|
| 04 Mar 2014 03:45 PM |
Bump.
I replaced the script with a localscript and the tool falls out of my hand. It will not weld like it should. Switching it back fixes the problem. |
|
|
| Report Abuse |
|
StackEnd
|
  |
| Joined: 20 Oct 2008 |
| Total Posts: 672 |
|
| |
KingJacko
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 3944 |
|
| |
StackEnd
|
  |
| Joined: 20 Oct 2008 |
| Total Posts: 672 |
|
|
| 04 Mar 2014 04:50 PM |
@above
Please read the post 2 above yours. |
|
|
| Report Abuse |
|