I have a gun that shoots, sounds, moves, and functions well in studio test mode, but everything changes when I make a server or play in-game mode.I have a gun with an aim script that aims the gun, a mouse texture to the gun, and sounds to the gun, when I go in-game or on a server it all disappears like it's just a random tool. What's wrong with it?
Link: https://www.roblox.com/item.aspx?id=589543784
Script Below:
--local humanoid = hit.Parent:FindFirstChild("Humanoid") --[[HeadDamage = 50 BodyDamage = 25 ArmDamage = 20]] Gun = script.Parent --Human = script.Parent.Parent.Humanoid.Health Ammo1 = 12 TotalAmmo1 = 24 Numerator1 = 12 DaClassName = script.Parent.Parent.ClassName BulletSpeed = 10 LimbDamage = 15 BodyDamage = 30 HeadDamage = 60 local GunOwner = script.Parent.Parent local player = game.Players:GetPlayerFromCharacter(GunOwner) local character = player.Character local mouse = player:GetMouse() local UserInputService = game:GetService("UserInputService") enabled = true -- SEMIAUTOMATIC function Equip() -- slot end --function Equippered() function Shoot() --if Human > 0 then if Ammo1 >= 1 and enabled == true then Ammo1 = Ammo1 - 1 print(Gun.Parent.Name .. " has " .. Ammo1 .." ammo out of " .. TotalAmmo1 .. " in storage.") enabled = false local Bullet = Instance.new("Part", Gun) Bullet.Anchored = false game.Debris:AddItem(Bullet, 2) Bullet.Shape = "Ball" local mesh = Instance.new("SpecialMesh", Bullet) mesh.MeshType = "Sphere" mesh.Scale = Vector3.new(1, 1, 3) Bullet.Size = Vector3.new(0.1, 0.1, 0.1) Bullet.TopSurface = "Smooth" Bullet.BottomSurface = "Smooth" Bullet.BrickColor = BrickColor.new() Bullet.CanCollide = false Bullet.CFrame = Gun.ShootThing.CFrame Bullet.CFrame = CFrame.new(Bullet.Position,mouse.Hit.p) local v = Instance.new("BodyVelocity", Bullet) v.velocity = Bullet.CFrame.lookVector * (BulletSpeed * 40) v.maxForce = Vector3.new(math.huge, math.huge, math.huge) --[[Gun.Fire.Transparency = 0.5 wait(0.2) Gun.Fire.Transparency = 1]] --[[local PE = Instance.new("ParticleEmmitter", Bullet) PE.]] --[[Gun.GunPos = Vector3.new(1.5, 0, math.random(0.3, 1)) wait(0.08) Gun.GunPos = Vector3.new(1.5, 0, 0)]] Gun.FireSound:Play() Bullet.Touched:connect(HitDamage) function HitDamage(Part) if Part.Parent:FindFirstChild("Humanoid") ~= nil then local player = game.Players.LocalPlayer --local player = Gun.Parent:GetPlayerFromCharacter() --[[local sound = Instance.new("Sound") sound.SoundId = "http://www.roblox.com/asset/?id=523817138" sound.Parent = player.PlayerGui]] if Part.Name == "Head" then Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health - HeadDamage mouse.Icon = "http://www.roblox.com/asset/?id=517291903" player.PlayerGui.HitSound:Play() Bullet:Destroy() end if Part.Name == "Right Leg" or "Left Leg" or "Right Arm" or "Left Arm" then Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health - LimbDamage mouse.Icon = "http://www.roblox.com/asset/?id=517291903" player.PlayerGui.HitSound:Play() Bullet:Destroy() end if Part.Name == "Torso" then Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health - BodyDamage mouse.Icon = "http://www.roblox.com/asset/?id=517291903" player.PlayerGui.HitSound:Play() Bullet:Destroy() end wait(0.3) mouse.Icon = "http://www.roblox.com/asset/?id=517269307" if Part.Parent.Humanoid.Health <= 0 then print(GunOwner.Name .. " has just killed " .. Part.Parent.Name) end --else --[[local GunShotDecalThing = Instance.new("Part", game.Workspace) GunShotDecalThing.Size = Vector3.new(0.3, 0.1, 0.3) GunShotDecalThing.CanCollide = false GunShotDecalThing.Anchored = true GunShotDecalThing.Position = Part.Position GunShotDecalThing.Transparency = 1 local GunShotDecal = Instance.new("Decal", GunShotDecalThing) GunShotDecal.Texture = "http://www.roblox.com/asset/?id=338514187" wait(5) GunShotDecalThing:Remove()]] end end end wait() enabled = true end --end --[[ local humanoid = hit.Parent:FindFirstChild("Humanoid") Bullet.Touched:connect(function(hit) if humanoid then humanoid:takeDamage(10) end end)]] function Death() if Gun.Parent == character then Gun.Parent = game.Workspace if Gun.Parent == game.Workspace then wait(20) Gun:Remove() end end end character.Humanoid.Died:connect(Death) local mouse = player:GetMouse() function OnKeyDown(key) key = key:lower() if key == "r" then print(player.Name .. " just clicked 'R' on the keyboard.") if TotalAmmo1 > 0 then print(Gun.Parent.Name .. "'s gun is reloading.") enabled = false wait(3) -- --[[print(TotalAmmo1) print(Numerator1) print(Ammo1)]] local AmmoMath = Ammo1+TotalAmmo1 > 12 and 12 or Ammo1+TotalAmmo1 TotalAmmo1 = TotalAmmo1 - (Numerator1 - Ammo1) if TotalAmmo1 < 0 then --AmmoMath = Ammo1+TotalAmmo1 TotalAmmo1 = 0 end Ammo1 = AmmoMath --Numerator1 enabled = true else print(Gun.Parent.Name .. " has run out of Ammunition.") end end end function BeenEquipted(Mouse) Mouse.Icon = "http://www.roblox.com/asset/?id=517269307" local camera = game.Workspace.CurrentCamera mouse.Button2Down:connect(function(Mouse) if script.Parent.Parent.ClassName == "Model" then wait() UserInputService.MouseIconEnabled = false Gun.GripPos = Vector3.new(0.3, 0, 0) wait(0.001) Gun.GripPos = Vector3.new(0.7, 0.1, 0) wait(0.001) Gun.GripPos = Vector3.new(1.1, 0.2, 0) wait(0.001) Gun.GripPos = Vector3.new(1.5, 0.3, 0) Gun.Parent.Humanoid.WalkSpeed = 10 camera.FieldOfView = 60 wait(0.001) camera.FieldOfView = 50 end end) mouse.Button2Up:connect(function(Mouse) if script.Parent.Parent.ClassName == "Model" then wait() UserInputService.MouseIconEnabled = true Gun.GripPos = Vector3.new(1.5, 0.3, 0) wait(0.001) Gun.GripPos = Vector3.new(1.1, 0.2, 0) wait(0.001) Gun.GripPos = Vector3.new(0.7, 0.1, 0) wait(0.001) Gun.GripPos = Vector3.new(0.3, 0, 0) wait(0.001) Gun.Parent.Humanoid.WalkSpeed = 16 camera.FieldOfView = 60 wait(0.001) camera.FieldOfView = 70 end end) end function Weld(x,y) local W = Instance.new("Weld") W.Part0 = x W.Part1 = y local CJ = CFrame.new(x.Position) local C0 = x.CFrame:inverse()*CJ local C1 = y.CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = x end function Get(A) if A.className == "Part" then Weld(script.Parent.Handle, A) A.Anchored = false else local C = A:GetChildren() for i=1, #C do Get(C[i]) end end end function Finale() Get(script.Parent) end function IsEquipped() player.CameraMode = "LockFirstPerson" end function IsUnEquipped() player.CameraMode = "Classic" end wait() Tool=script.Parent CP,Torso,g=nil,nil,nil necko=CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0) getPos=function(Pos,TorsoPos) return Vector3.new(Pos.x,TorsoPos.y,Pos.z) end Turn=function(mouse,Torso,Gyro) g.cframe=CFrame.new(Torso.Position,getPos(mouse.Hit.p,Torso.Position)) offset=(Torso.Position.y-mouse.Hit.p.y)/130 mag=(Torso.Position-mouse.Hit.p).magnitude/140 offset=offset/mag neck=Torso.Neck neck.C0=necko*CFrame.fromEulerAnglesXYZ(offset,0,0) arm=Torso:FindFirstChild("Right Shoulder") if arm~=nil then arm.C0=CFrame.new(1, 0.5, 0, 0, 0, 1, -6.48200512e-007, 1.00000274, 0, -1.00000274, -6.48200512e-007, 0)*CFrame.fromEulerAnglesXYZ(0,0,-offset) end end Equi=function(mouse) wait(.2) CP=Tool.Parent Torso=CP.Torso g=Instance.new("BodyGyro") g.P=18000 g.D=600 g.maxTorque=Vector3.new(80000,80000000,80000)*50000000000000000000000000 g.cframe=Torso.CFrame g.Parent=Torso while true do if Tool.Parent.className~="Model" then break end Turn(mouse,Torso,g) wait() end Torso.Neck.C0=necko g:Remove() end Tool.Equipped:connect(Equi) script.Parent.Equipped:connect(Finale) script.Parent.Unequipped:connect(Finale) Finale() function Shot() Gun.ShootEnd.Mesh.Offset = Vector3.new(0, 0, 0.3) Gun.ShootEnd2.Mesh.Offset = Vector3.new(0, 0, 0.3) Gun.ShootEnd3.Mesh.Offset = Vector3.new(0, 0, 0.3) Gun.ShootEnd4.Mesh.Offset = Vector3.new(0, 0, 0.3) Gun.ShootEnd5.Mesh.Offset = Vector3.new(0, 0, 0.3) Gun.ShootEnd6.Mesh.Offset = Vector3.new(0, 0, 0.3) Gun.ShootEnd7.Mesh.Offset = Vector3.new(0, 0, 0.3) Gun.Color.Mesh.Offset = Vector3.new(0, 0.3, 0) wait(0.1) Gun.ShootEnd.Mesh.Offset = Vector3.new(0,0,0) Gun.ShootEnd2.Mesh.Offset = Vector3.new(0, 0, 0) Gun.ShootEnd3.Mesh.Offset = Vector3.new(0, 0, 0) Gun.ShootEnd4.Mesh.Offset = Vector3.new(0, 0, 0) Gun.ShootEnd5.Mesh.Offset = Vector3.new(0, 0, 0) Gun.ShootEnd6.Mesh.Offset = Vector3.new(0, 0, 0) Gun.ShootEnd7.Mesh.Offset = Vector3.new(0, 0, 0) Gun.Color.Mesh.Offset = Vector3.new(0, 0, 0) end Gun.Activated:connect(Shot) mouse.KeyDown:connect(OnKeyDown) Gun.Activated:connect(Shoot) Gun.Equipped:connect(Equip) --script.Parent.Equipped:connect(Equippered) script.Parent.Equipped:connect(BeenEquipted) script.Parent.Equipped:connect(IsEquipped) script.Parent.Unequipped:connect(IsUnEquipped)
Not trying to sound like a douche-bag here, but it's hard to help if you don't provide us with any error. Go into your game and Press F9 for developer console, and you will see the error there, thus fixing it shouldn't be that hard.