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

Why is my weapon not shooting when I moved?

Asked by
naturedat 124
4 years ago
Edited 4 years ago

Hi, I'm making a magic staff. The problem is when I stand still, it shoots but when I moved, it doesn't and sometimes it shoot down. I have tried anchored the magic but then when I clicked, the magic only spawn and it didn't move. It would be great if you can help me fix my script and I also need to make a cool down for my weapon but I don't know how. This is my script:

script.Parent.Activated:Connect(function(plr)
    local magic = game.ServerStorage:WaitForChild("Magic")
    local NewMagic = magic:Clone()
    NewMagic.Parent = script.Parent
    NewMagic.CFrame = script.Parent.Core.CFrame

    local velocity = Instance.new("BodyVelocity")
    velocity.Parent = NewMagic
    velocity.MaxForce = Vector3.new(4000,4000,4000)
    NewMagic.CFrame = script.Parent.Core.CFrame
    velocity.Velocity = (NewMagic.Parent.Core.CFrame.lookVector*100)
    wait(0.5)
    NewMagic:Destroy()
end)

I placed this script in the tool, the 'Core' is a part of my weapon, it is where I want my weapon to spawn the magic and shoot it from there. I had customized the magic and put it into the ServerStorage. This weapon only shoots forward, I don't know how to make it move to the point where I clicked at so it would also be great if you can help me with this.

0
Oh and I don't understand the thing where we put in a bracket after function => function('A thing') naturedat 124 — 4y
0
whent should u it shoot? shoot when clicked or something else? Erie20 102 — 4y
0
also, you should used tool.Activated and use mouse.Hit.Position to detect where it clicked. https://developer.roblox.com/en-us/api-reference/event/Tool/Equipped Erie20 102 — 4y
0
Thank you! naturedat 124 — 4y

1 answer

Log in to vote
0
Answered by
YODARM 5
3 years ago

For they cool down i think you should probably use a debounce there are a lot of videos on it on youtube :)

Ad

Answer this question