Rocket Laucnher dont working

Hi dev’s! I just wanted make rocket launcher but after copying from this video: (2) Program a rocket launcher on roblox (3 EASY STEPS) - YouTube
I have problem, rocket not lauching and exploded:
image

Server script:

local p = script.Parent
local h = p.Handle
local fe = p.Fire
local rs1 = 25
local rpv = h.Rocket

fe.OnServerEvent:Connect(function(plr,aim)
	local rp = game.ServerStorage.RocketPart:Clone()
	rp.Parent = workspace
	rp.CFrame = CFrame.new(h.RocketAttachment.Position,aim.Position)
	rp.CanCollide = false
	rp.Velocity = rp.CFrame.LookVector * rs1
	
	local bf = Instance.new("BodyForce")
	bf.Parent = rp
	bf.Force = Vector3.yAxis * workspace.Gravity * rp.Mass
	
	rp.Touched:Connect(function(hit)
		if not hit:IsDescendantOf(plr.Character) then
			local e = Instance.new("Explosion")
			e.Parent = workspace
			e.Position = rp.Position
			rp:Destroy()
		end
	end)
end)

Local script:

local p = script.Parent
local fe = p.Fire
local lp = game.Players.LocalPlayer
local m = lp:GetMouse()
local rs = 1
local db = true

p.Activated:Connect(function()
	if db then
		db = false
		fe:FireServer(m.Hit)
		wait(rs)
		db = true
	end
end)

Have a nice day!

1 Like

It’s because an Attachment’s Position property is in Object Space relative to it’s parent, and not in World Space. You would have to replace it with this:

rp.CFrame = CFrame.new(h.RocketAttachment.WorldPosition,aim.Position)

Another unrelated problem with your script, it’s a terrible idea to keep a debounce solely on the client, because it allows exploiters to ignore the cooldown all together.

2 Likes

Thank you too much! lolz))))))))))) :star_struck:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.