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

Shooting a block with bodyVelocity?

Asked by
Kryddan 261 Moderation Voter
10 years ago

I try to do so whenever i press the "Y" button i should shoot away a block from myself into the direction where my mouse is. It works until i move, if i move and then press "Y" the block spawns but never shoots away it just sits still.

here is my code and i hope you can help me.

01local player = game.Players.LocalPlayer
02local mouse = player:GetMouse()
03 
04mouse.KeyDown:connect(function(key)
05    key:lower()
06    if key == "y"  then
07        local x = Instance.new("Part", workspace)
08        x.Size = Vector3.new(5,5,5)
09        x.Name = "FlyingBrick"
10        x.BrickColor = BrickColor.Random()
11        x.TopSurface = "Smooth"
12        x.BottomSurface = "Smooth"
13        x.Material = "Concrete"
14        x.CFrame = player.Character.Torso.CFrame + Vector3.new(0,1,0)      
15        x.Anchored = false
View all 22 lines...

1 answer

Log in to vote
0
Answered by
SurVur 86
10 years ago

xvelocity.velocity = CFrame.new(player.Character.Torso.Position, mouse.Hit.p).lookVector * 50

replace line 20 with this

0
Thx for the answer but it still won't work! Kryddan 261 — 10y
0
never mind i just removed line 19 xvelocity.P = 1250 and it worked! Kryddan 261 — 10y
Ad

Answer this question