Hello everyone!
Im tried test rocket launchers form toolbox, and i found this model: https://create.roblox.com/store/asset/6102273316/Working-Classic-Rocket-Launcher?viewFromStudio=true&keyword=&searchId=C5DD3892-2064-4C77-8299-5C81CEBBD024
And i found funny or abussive bug: If server have two or more players with rocket launcher, all rocket lauchers can lauch two or more rockets.
Local script:
local mouse = game.Players.LocalPlayer:GetMouse()
local player = game.Players.LocalPlayer
local Tool = script.Parent
script.Parent.Activated:Connect(function()
local myModel = player.Character
if Tool.Enabled and myModel and myModel:FindFirstChild('Humanoid') and myModel.Humanoid.Health > 0 then
Tool.Enabled = false
game.ReplicatedStorage.ROBLOX_RocketFireEvent:FireServer(mouse.Hit.p)
wait(3)
Tool.Enabled = true
end
end)
Server script:
local Rocket = Instance.new("Part")
local Tool = script.Parent
Rocket.Locked = true
Rocket.BackSurface = 3
Rocket.BottomSurface = 3
Rocket.FrontSurface = 3
Rocket.LeftSurface = 3
Rocket.RightSurface = 3
Rocket.TopSurface = 3
Rocket.Size = Vector3.new(1,1,4)
Rocket.BrickColor = BrickColor.new(23)
Tool.RocketScript:clone().Parent = Rocket
Tool.Explosion:clone().Parent = Rocket
Tool.Swoosh:clone().Parent = Rocket
local function createEvent(eventName)
local event = game.ReplicatedStorage:FindFirstChild(eventName)
if not event then
event = Instance.new("RemoteEvent", game.ReplicatedStorage)
event.Name = eventName
end
return event
end
local updateEvent = createEvent("ROBLOX_RocketUpdateEvent")
local equipEvent = createEvent("ROBLOX_RocketEquipEvent")
local unequipEvent = createEvent("ROBLOX_RocketUnequipEvent")
local fireEvent = createEvent("ROBLOX_RocketFireEvent")
function fire(player, vTarget)
local vCharacter = Tool.Parent;
local vHandle = Tool:findFirstChild("Handle")
if vHandle == nil then
print("Handle not found")
return
end
local dir = (vTarget - vHandle.Position).unit
local missile = Rocket:clone()
local pos = vHandle.Position + (dir * 10)
print(" ")
print(vTarget)
print(dir)
--missile.Position = pos
missile.CFrame = CFrame.new(pos, pos + dir)
local creator_tag = Instance.new("ObjectValue")
local vPlayer = game.Players:playerFromCharacter(vCharacter)
if vPlayer == nil then
print("Player not found")
else
if (vPlayer.Neutral == false) then -- nice touch
missile.BrickColor = vPlayer.TeamColor
end
end
creator_tag.Value =vPlayer
creator_tag.Name = "creator"
creator_tag.Parent = missile
missile.RocketScript.Disabled = false
missile.Parent = game.Workspace
end
fireEvent.OnServerEvent:Connect(fire)
Tool.Enabled = true