Hello dev’s! I know i maked topic simmilar with this. But roblox printing " Fire is not a valid member of Tool “Players.plr.Backpack.PainBallGun”"
Local srcipt:
local p = script.Parent
local fe = p.Fire
local lp = game.Players.LocalPlayer
local m = lp:GetMouse()
local rs1 = 0.5
local rs2 = 2
local b = 30
local db = true
local al = nil
local al2 = nil
local al3 = nil
p.Equipped:Connect(function()
local hum1 = lp.Character.Humanoid
if hum1 ~= nil then
al3 = hum1:LoadAnimation(p.Handle.Idle)
al3:Play()
end
end)
p.Activated:Connect(function()
if b >= 0 then
if db then
db = false
local hum = lp.Character.Humanoid
if hum ~= nil then
al = hum:LoadAnimation(p.Handle.Shot)
al:Play()
end
fe:FireServer(m.Hit)
wait(rs1)
db = true
end
else
if db == true then
db = false
local hum = lp.Character.Humanoid
if hum ~= nil then
al = hum:LoadAnimation(p.Handle.Fire)
al:Play()
wait(rs2)
db = true
end
end
end
end)
p.Unequipped:Connect(function()
if al3 then
al3:Stop()
al3 = nil
end
end)
Server script:
local p = script.Parent
local h = p.Handle
local fe = p.Fire
local rs1 = 150
fe.OnServerEvent:Connect(function(plr,aim)
local rp = game.ServerStorage.Ball:Clone()
rp.BrickColor = BrickColor.random()
rp.Parent = workspace
rp.CFrame = CFrame.new(h.RocketAttachment.WorldPosition,aim.Position)
rp.Velocity = rp.CFrame.LookVector * rs1
h.Fire:Play()
local bf = Instance.new("BodyForce")
bf.Parent = rp
bf.Force = Vector3.yAxis * workspace.Gravity * rp.Mass
rp.Touched:Connect(function(hit)
if hit:IsDescendantOf(plr.Character) then
local h = hit:FindFirstChild("Humanoid")
if h then
h.Health = h.Health - 30
end
rp:Destroy()
end
end)
end)