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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Gun Problem (Revised)

Previous Thread :: Next Thread 
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
13 Aug 2013 01:15 PM
Since everybody was discouraged by how big the script was, ima revise the problem.

I have a script, and it works in everything but Online mode. It used to work, but then I put these inside the script:

Variable:
stenanimate = script.StenAnimate:Clone()
Inside Equipped function:
stenanim.Parent = character
stenanim.Disabled = false
Inside Unequipped function:
stenanim.Parent = nil

StenAnimate IS inside the script (Basically Animate with RShoulder and LShoulder taken out).

Here is the full script, if you need StenAnimate just ask:

s = script.Parent
ammo = script.Parent.AmmoGui:Clone()
stenanim = script.StenAnimate:Clone()
player = game.Players.LocalPlayer
character = player.Character
rs = character.Torso["Right Shoulder"]
ls = character.Torso["Left Shoulder"]
rh = character.Torso["Right Hip"]
lh = character.Torso["Left Hip"]
reload = false
isready = false
currentcamera = Workspace.CurrentCamera
q = false
e = false

s.Equipped:connect(function(mouse)
wait(0.01)
for i, v in ipairs(s.Handle:GetChildren()) do if v:IsA("Weld") then v:Destroy() end end
for i, v in ipairs(s.Clip1:GetChildren()) do if v:IsA("Weld") then v:Destroy() end end
for i, v in ipairs(character.Torso:GetChildren()) do if v:IsA("Motor6D") then v.MaxVelocity = 0.3 end end
if character:FindFirstChild("Animate") then
character.Animate.Disabled = true
end
function weld(part0,part1,c0)
local weld = Instance.new("Weld",part0)
for n,o in pairs({C0=c0,Part0=part0,Part1=part1})do
weld[n] = o
end
return weld end
rarm = character["Right Arm"]:Clone()
larm = character["Left Arm"]:Clone()

h = s.Handle
weld(h,s.BackSight1,CFrame.new(0.06,0.47,-0.7))
weld(h,s.BackSight2,CFrame.new(-0.06,0.47,-0.7))
weld(h,s.BackSightDecoration1,CFrame.new(0.06, 0.54, -0.7))
weld(h,s.BackSightDecoration2,CFrame.new(-0.06, 0.54, -0.7))
weld(h,s.BarrelHole,CFrame.new(0, 0.3, 1.53)*CFrame.Angles(math.rad(90),0,0))
weld(h,s.Body,CFrame.new(0,0.3,0.37)*CFrame.Angles(math.rad(90),0,0))
clip = weld(h,s.Clip1,CFrame.new(0.33,0.3,0.32)) -- Clip variable
weld(s.Clip1,s.Clip2,CFrame.new(0.154,0,0.008)*CFrame.Angles(0,math.rad(-11),0))
weld(s.Clip1,s.Clip3,CFrame.new(0.379,0,0.064)*CFrame.Angles(0,math.rad(-15),0))
weld(h,s.ClipHold,CFrame.new(0.27,0.3,0.32))
weld(h,s.ClipHole,CFrame.new(0.3,0.3,0.32))
weld(h,s.FakeHandle,CFrame.new(0,0,0)*CFrame.Angles(math.rad(20),0,0))
weld(h,s.FakeLight,CFrame.new(0,0.08,1.51)*CFrame.Angles(math.rad(90),0,0))
weld(h,s.FrontSight,CFrame.new(0,0.49,1.55))
weld(h,s.HandleDecoration1,CFrame.new(0,-0.188,-0.068)*CFrame.Angles(math.rad(20),0,0))
weld(h,s.HandleDecoration2,CFrame.new(0, -0.094, -0.034)*CFrame.Angles(math.rad(20),0,0))
weld(h,s.HandleDecoration3,CFrame.new(0,0,0)*CFrame.Angles(math.rad(20),0,0))
weld(h,s.Light,CFrame.new(0,0.08,1.51)*CFrame.Angles(math.rad(-180),0,0))
weld(h,s.Lighthold,CFrame.new(0,0.09,1.45))
weld(h,s.Stock1,CFrame.new(0,0.31,-1.24))
weld(h,s.Stock2,CFrame.new(0,0.14,-1.44))
weld(h,s.StockHold1,CFrame.new(0.19,0.31,-0.93))
weld(h,s.StockHold2,CFrame.new(-0.19,0.31,-0.93))
weld(h,s.StockHold3,CFrame.new(0,0.31,-1.04))
weld(h,s.StockHold4,CFrame.new(-0.149, 0.31, -0.754)*CFrame.Angles(0,math.rad(39),0))
weld(h,s.StockHold5,CFrame.new(0.153, 0.31, -0.758)*CFrame.Angles(0,math.rad(-39),0))
weld(h,s.Trigger,CFrame.new(0,0.11,0.258)*CFrame.Angles(math.rad(-9),0,0))
weld(h,s.Triggercover,CFrame.new(0,0.1,0.4))
weld(h,s.TriggercoverBottom,CFrame.new(0,0.01,0.27))
rarm.Parent = script.Parent
larm.Parent = script.Parent
rarm.Transparency = 0.3
larm.Transparency = 0.3
rarm.CanCollide = false
larm.CanCollide = false
rarm.Name = "FakeRight"
larm.Name = "FakeLeft"
weld(character["Right Arm"],rarm,CFrame.new(0,0,0))
weld(character["Left Arm"],larm,CFrame.new(0,0,0))
ammo.Parent = game.Players.LocalPlayer.PlayerGui
wait()
ls:SetDesiredAngle(math.rad(-90))
lh:SetDesiredAngle(0)
rh:SetDesiredAngle(0)
rs:SetDesiredAngle(math.rad(90))
rs.C0 = CFrame.new(0.6,0.4,rs.C0.Z)*CFrame.Angles(0,math.rad(105),0)
ls.C0 = CFrame.new(-0.2, 0.6, -0.5)*CFrame.Angles(0,math.rad(-100),0)
character["Right Arm"].Transparency = 1
character["Left Arm"].Transparency = 1
stenanim.Disabled = false
stenanim.Parent = character
mouse.Icon = "rbxasset://textures\\GunCursor.png"
isready = true

bdown = false
mouse.Button1Down:connect(function()
if isready == true then
damage = true
function GetBullet(hit)
local ignore = character:GetChildren()
for i, v in ipairs(hit.Parent:GetChildren()) do
for i = 1, #ignore do
if ignore[i] == hit then
damage = false
end
end
if v:IsA("Humanoid") and damage == true then
v:TakeDamage(math.random(3,7))
end
end
end
bdown = true
while bdown and wait(0.15) and script.Parent.Ammo.Value > 0 and reload == false do
local mH = mouse.Hit
local pa = Instance.new("Part",Workspace)
local v = Instance.new("BodyVelocity",pa)
local sound = Instance.new("Sound",script.Parent.Handle)
local sw = coroutine.wrap(function()repeat wait() until sound.IsPlaying == false sound:Destroy() end)
local w = coroutine.wrap(function() wait(5) if pa ~= nil then pa:Destroy() end end)
local cc = coroutine.wrap(function() currentcamera.Focus = CFrame.new(currentcamera.Focus.X+0.015,currentcamera.Focus.Y+0.025,currentcamera.Focus.Z) wait(0.05) currentcamera.Focus = CFrame.new(currentcamera.Focus.X-0.01,currentcamera.Focus.Y-0.02,currentcamera.Focus.Z) end)
script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
pa.FormFactor = 3
pa.Size = Vector3.new(.2,.2,.2)
pa.BrickColor = BrickColor.DarkGray()
pa.CFrame = script.Parent.Handle.CFrame * CFrame.new(script.Parent.Parent.Torso.CFrame.lookVector * 2)
pa.CFrame = CFrame.new(pa.Position, mH.p)
v.maxForce = Vector3.new(10000,10000,10000)
v.P = 6000
v.velocity = pa.CFrame.lookVector * 120
pa.Touched:connect(GetBullet)
sound.SoundId = "http://www.roblox.com/asset/?id=13510352"
sound.Pitch = 1
sound.Volume = 1
sound:Play()
cc()
w()
sw()
end
end
end)

mouse.Button1Up:connect(function()
bdown = false
end)

mouse.KeyDown:connect(function(key)
if key == "r" and bdown == false and reload == false and s.Ammo.Value ~= s.MaxAmmo.Value and isready == true then
reload = true
local sound = Instance.new("Sound",script.Parent.Handle)
sound.SoundId = "http://www.roblox.com/asset/?id=2697432"
sound.Volume = 1
sound:Play()
for i = 1, 8 do
wait(0.05)
clip.C0 = CFrame.new(clip.C0.X+0.1,clip.C0.Y,clip.C0.Z)
ls.C0 = CFrame.new(ls.C0.X-0.1,ls.C0.Y,ls.C0.Z)*CFrame.Angles(0,math.rad(-100),0)
end
s.Clip1.Transparency = 1
s.Clip2.Transparency = 1
s.Clip3.Transparency = 1
ls:SetDesiredAngle(math.rad(-15))
wait(0.38)
ls:SetDesiredAngle(math.rad(-90))
wait(0.4)
s.Clip1.Transparency = 0
s.Clip2.Transparency = 0
s.Clip3.Transparency = 0
for i = 1, 8 do
wait(0.05)
clip.C0 = CFrame.new(clip.C0.X-0.1,clip.C0.Y,clip.C0.Z)
ls.C0 = CFrame.new(ls.C0.X+0.1,ls.C0.Y,ls.C0.Z)*CFrame.Angles(0,math.rad(-100),0)
end
script.Parent.Ammo.Value = script.Parent.MaxAmmo.Value
sound:Destroy()
reload = false
elseif key == "f" and reload == false and bdown == false then
if s.Light.SpotLight.Enabled == false and reload == false and bdown == false then
ls.C0 = CFrame.new(ls.C0.X,ls.C0.Y,ls.C0.Z-0.5)*CFrame.Angles(0,math.rad(-100),0)
s.Light.SpotLight.Enabled = true
wait(0.1)
ls.C0 = CFrame.new(ls.C0.X,ls.C0.Y,ls.C0.Z+0.5)*CFrame.Angles(0,math.rad(-100),0)
elseif s.Light.SpotLight.Enabled == true and reload == false and bdown == false then
ls.C0 = CFrame.new(ls.C0.X,ls.C0.Y,ls.C0.Z-0.5)*CFrame.Angles(0,math.rad(-100),0)
s.Light.SpotLight.Enabled = false
wait(0.1)
ls.C0 = CFrame.new(ls.C0.X,ls.C0.Y,ls.C0.Z+0.5)*CFrame.Angles(0,math.rad(-100),0)
end
elseif key == "q" then
q = true
if rarm.Transparency < 0.8 and larm.Transparency < 0.8 then
rarm.Transparency = rarm.Transparency + 0.05
larm.Transparency = larm.Transparency + 0.05
wait(0.3)
if q == true then
repeat
wait(0.1)
if q == true and rarm.Transparency < 0.7 and larm.Transparency < 0.7 then
rarm.Transparency = rarm.Transparency + 0.05
larm.Transparency = larm.Transparency + 0.05
end
until q == false
end
elseif rarm.Transparency == 1 and larm.Transparency == 1 then
character["Right Arm"].Transparency = 0
character["Left Arm"].Transparency = 0
end
elseif key == "e" then
e = true
if rarm.Transparency ~= 0 and larm.Transparency ~= 0 then
rarm.Transparency = rarm.Transparency - 0.05
larm.Transparency = larm.Transparency - 0.05
wait(0.3)
if e == true then
repeat
wait(0.1)
if e == true and rarm.Transparency > 0 and larm.Transparency > 0 then
rarm.Transparency = rarm.Transparency - 0.05
larm.Transparency = larm.Transparency - 0.05
end
until e == false
end
elseif rarm.Transparency == 0 and larm.Transparency == 0 then
character["Right Arm"].Transparency = 1
character["Left Arm"].Transparency = 1
end
end
end)
mouse.KeyUp:connect(function(key)
if key == "q" and isready == true then
q = false
elseif key == "e" and isready == true then
e = false
end
end)
end)

s.Unequipped:connect(function()
function clear(parent,object)
for i, v in ipairs(parent:GetChildren()) do
if v:IsA(object) then
v:Destroy()
end
end
end
character.Animate.Disabled = false
for i, v in ipairs(character.Torso:GetChildren()) do if v:IsA("Motor6D") then v.MaxVelocity = 0.1 end end
if script.Parent.Parent ~= Workspace then
clear(s.Handle,"Weld")
clear(s.Clip1,"Weld")
clear(character["Right Arm"],"Weld")
clear(character["Left Arm"],"Weld")
rarm:Destroy()
larm:Destroy()
character["Right Arm"].Transparency = 0
character["Left Arm"].Transparency = 0
end
clear(s.Handle,"Sound")
ammo.Parent = nil
ls.C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
rs.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
stenanim.Parent = nil
isready = false
end)

s.Ammo.Changed:connect(function()
ammo.Ammo.Text = tostring(s.Ammo.Value).."/"..tostring(s.MaxAmmo.Value)
end)
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
13 Aug 2013 01:17 PM
Ever occur to you to post output?

You're in immortal danger bow down praise to your lord and savior.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
13 Aug 2013 01:22 PM
@flat

No output, because I stated that it worked in all but Online, and this is in a LocalScript, so it Remote Monitor Error System doesn't pick up errors from there, plus the RMES will error if put into a LocalScript.
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
13 Aug 2013 01:31 PM
Go to: ->Start Server ->Start Player

Then get the output. If none show which part isn't working.

You're in immortal danger bow down praise to your lord and savior.
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
13 Aug 2013 01:35 PM
Put wait(0.1) at the top of the LocalScript.

~ Oh, I'm sorry, did I break your concentration? ~
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
13 Aug 2013 01:42 PM
@Flat

Pretty sure I've already done that before, and it worked in there, lemme see....
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
13 Aug 2013 01:45 PM
repeat wait(.5) until character
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
13 Aug 2013 01:45 PM
@Flat

Works fine in there, yet it doesn't work online. Here is the place I used for testing:

http://www.roblox.com/Strangely-Random-Testing-place?id=101760992
Report Abuse
expressmyself is not online. expressmyself
Joined: 19 Apr 2011
Total Posts: 1768
13 Aug 2013 01:52 PM
remember welds break when changing parents... ANyway also fix the thing if you press backspace...
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
13 Aug 2013 01:54 PM
@express

No, that doesn't really help. As I stated, it worked before I added that stuff I mentioned in first post.
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
13 Aug 2013 01:59 PM
Did you put a wait(0.1) at the beginning?

~ Oh, I'm sorry, did I break your concentration? ~
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
13 Aug 2013 02:03 PM
- Local Script right?

player.CharacterAdded:wait()
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
13 Aug 2013 02:05 PM
@Raphael

Yeah, LocalScript.

Um, what do I do with that line?

@MHebes

I think I put like a wait() at the top.
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
13 Aug 2013 02:07 PM
Put,

repeat wait(1/30) until game.Players.LocalPlayer
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
13 Aug 2013 02:11 PM
@Rapheal

I put it @ beginning of Equipped function?
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
13 Aug 2013 02:14 PM
Before the whole script loads.

-- Put the wait here

-- Put all the script here.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
13 Aug 2013 02:15 PM
Oh, I put it inside the Equipped function. I'll try that.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
13 Aug 2013 02:18 PM
@Raphael

Thanks, it works now.
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