I was making a gun and it worked in solo mode but not in the server mode. I tried to make it work but it doesn't work.
Bin = script.Parent
player = game.Players.LocalPlayer
camera = game.Workspace.CurrentCamera
mouse = player:GetMouse()
BulletSpeed = script.Parent.Configuration.BulletSpeed.Value
function Light()
script.Parent.Light.Transparency = 0.5
script.Parent.Light.SpotLight.Enabled = true
script.Parent.Shoot:Play()
wait()
script.Parent.Light.Transparency = 1
script.Parent.Light.SpotLight.Enabled = false
end
function FOVIn()
camera.FieldOfView = camera.FieldOfView - 5
end
function FOVOut()
camera.FieldOfView = camera.FieldOfView + 5
end
function weld()
local parts,last = {}
local function scan(parent)
for _,v in pairs(parent:GetChildren()) do
if (v:IsA("BasePart")) then
if (last) then
local w = Instance.new("Weld")
w.Name = ("%s_Weld"):format(v.Name)
w.Part0,w.Part1 = last,v
w.C0 = last.CFrame:inverse()
w.C1 = v.CFrame:inverse()
w.Parent = last
end
last = v
table.insert(parts,v)
end
scan(v)
end
end
scan(script.Parent)
for _,v in pairs(parts) do
v.Anchored = false
end
end
function Shoot()
local Ammo = player.PlayerGui.FPS.Ammo
local H = player.PlayerGui.Status.StatusFrame.Health.Text
local Cooldown = false
if Cooldown == false then
if tonumber(Ammo.Text.Text) == 0 then
script.Parent.Reloading.Value = true
Reload = player.Character.Humanoid:LoadAnimation(script.Parent.GunReload)
Reload:Play()
Ammo.Text.Text = "Reloading"
Ammo.Bar:TweenSize(UDim2.new(0,300,1,0),"InOut","Quad",4)
script.Parent.ChangeReload.Disabled = false
elseif script.Parent.Reloading.Value == false then
local Bullet = Instance.new("Part",game.Workspace)
Bullet.FormFactor = "Custom"
Bullet.Size = Vector3.new(0.1,0.1,0.1)
Bullet.Position = script.Parent.Hole.Position
Bullet.CFrame = CFrame.new(Bullet.Position,mouse.Hit.p)
Bullet.BrickColor = BrickColor.new("Really black")
Bullet.CanCollide = false
local Rocket = Instance.new("BodyVelocity",Bullet)
Rocket.maxForce = Vector3.new(math.huge,math.huge,math.huge)
Rocket.velocity = Bullet.CFrame.lookVector * BulletSpeed
findScript = Bullet:FindFirstChild("TakeDamage")
if TakeDamage == nil then
local Script = script.TakeDamage:Clone()
Script.Parent = Bullet
Script = script.TakeDamage:Clone()
Script.Parent = Bullet
Val = script.Parent.Configuration.Damage:Clone()
Val.Parent = Script
Script.Creator.Value = player.Name
Script.Disabled = false
end
Ammo.Text.Text = Ammo.Text.Text - 1
Ammo.Bar.Size = UDim2.new(0,tonumber(Ammo.Text.Text) * 10 * 3,1,0)
Light()
script.Parent.Shoot:Play()
Cooldown = true
wait(0.2)
Cooldown = false
end
end
end
function UnEquipped()
player.CameraMode = "Classic"
script.Disabled = true
end
weld()
Bin.Activated:connect(Shoot)
Bin.Unequipped:connect(UnEquipped)
mouse.WheelForward:connect(FOVIn)
mouse.WheelBackward:connect(FOVOut)
