Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

i'm trying to make a rocket launcher but my script doesn't work?

Asked by 3 years ago
Edited 3 years ago

i couldn't find the problem because there were no errors in the script analysis my scripts below 1st script ( local script )

local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local T = script.Parent
local handle = T:WaitForChild('Handle')
local debounce = true

T.Activated:Connect(function()
    local H = T.Parent:FindFirstChildWhichIsA("Humanoid")
    if H and debounce ~= true then
        debounce = false
        local position = mouse.Hit.Position
        T.RemoteEvent:FireServer(position)
        wait(5)
        debounce = true
    end
end)

2nd script (server script)

local T = script.Parent
local handle = script.Parent.Handle

T.RemoteEvent.OnServerEvent:Connect(function(player, position)
    local rocket = Instance.new("Part")
    rocket.Parent = workspace
    rocket.CFrame = CFrame.new(handle.Position, position)
    rocket.Size = Vector3.new(1,1,1)
    rocket.BrickColor = BrickColor.Black()
    local velocity = Instance.new("BodyVelocity")
    velocity.Parent = rocket
    velocity.Velocity = position - handle.Position.Unit*25
    velocity.MaxForce = Vector3.new('inf','inf','inf')
    rocket.Touched:Connect(function(hit)
        if hit ~= handle and not T.Parent:FindFirstChild(hit.Name) then
            local exp = Instance.new("Explosion")
            exp.Parent = workspace
            exp.Position = rocket.Position
            rocket:Destroy()
        end
    end)
end)

i don't know which one has the problem so i sent both the first script says that if i press i have to wait how many seconds till i can shoot another rocket the second one is the rocket ( i think ) edit:the problem is that it wont fire the rocket

0
are there any errors? Mroczusek 111 — 3y
0
there are no errors in script analysis bruce_matthew 4 — 3y
0
it won't fire the rocket i did what i can but no it didn't work bruce_matthew 4 — 3y
0
it doesn't creat part or explosion bruce_matthew 4 — 3y
View all comments (2 more)
0
answered now bruce_matthew 4 — 3y
0
don't need to answer it anmore its already answered bruce_matthew 4 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Debounce is set to true while firing it requires it NOT to be true.

Ad

Answer this question