I have alot of scripts here and I dont think they go in code review.
I want these scripts to make a rocket in rs close to the workspace and go to the mouses position and if it comes in contact with anything except the player or the tool.
Server script in tool:
local tool = script.Parent
local fireEvent = tool:WaitForChild("Fire")
fireEvent.OnServerEvent:Connect(function(plr, mouseHit, coolDown)
game.ReplicatedStorage.Fire:FireAllClients(plr, mouseHit,tool)
end)
Local script in tool:
local tool = script.Parent
local fireEvent = tool:WaitForChild("Fire")
coolDown = 3
canFire = true
tool.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
if canFire then
fireEvent:FireServer(mouse.Hit.Position, coolDown)
canFire = false
wait(coolDown)
canFire = true
end
end)
end)
Server script in server script service:
local debris = game:GetService("Debris")
game.ReplicatedStorage.Fire.OnServerEvent:Connect(function(plr, rocketPos, mouseHit)
local explosionPart = Instance.new("Part", workspace)
explosionPart.Anchored = true
explosionPart.CanCollide = false
explosionPart.Transparency = 1
explosionPart.Position = rocketPos
local explosion = Instance.new("Explosion", workspace)
explosion.Position = explosionPart.Position
debris:AddItem(explosionPart, 3)
end)
Local script in starterplayer:
local debris = game:GetService("Debris")
game.ReplicatedStorage.Fire.OnClientEvent:Connect(function(plr, mouseHit, tool)
local rocket = game.ReplicatedStorage.Rocket:Clone()
rocket.Parent = workspace
rocket.CFrame = CFrame.new(tool.EnhancedCone.Position, mouseHit)
local bv = Instance.new("BodyVelocity", rocket)
bv.Velocity = CFrame.new(rocket.Position, mouseHit).LookVector * 100
rocket.Touched:Connect(function(hit)
if hit:IsA("BasePart") then
if hit.Parent ~= tool then
rocket:Destroy()
game.ReplicatedStorage.Fire:FireServer(rocket.Position, mouseHit)
end
end
debris:AddItem(rocket, 3)
end)
end)
What its doing is, its detonating when they click instantly.
Please help!