Hey guys, excuse my ignorance in tool making. This is probably the first tool I've ever made on Roblox. I'm trying to make a wand that executes "magic" like bullets. It works similar to a gun.
The tool works perfectly when I'm standing at 0,0,0. When I move anywhere else, the wand makes "bullets" but they are static and don't behave like they should.
Here's the code:
plr = game.Players.LocalPlayer
gn = script.Parent
mouse = plr:GetMouse()
function Fire()
local bullet = Instance.new("Part", workspace)
game.Debris:AddItem(bullet, 3)
bullet.Shape = "Ball"
bullet.TopSurface = "Smooth"
bullet.BottomSurface = "Smooth"
bullet.BrickColor = BrickColor.new("Black")
bullet.CanCollide = false
bullet.CFrame = gn.Handle.CFrame
bullet.CFrame = CFrame.new(bullet.Position,mouse.Hit.p)
bullet.Anchored = false
local ps = Instance.new("BodyPosition", bullet)
ps.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
ps.Position = Vector3.new(mouse.Hit.p)
print(mouse.Hit.p)
end
gn.Activated:connect(Fire)
Here's how the wand behaves when I have not moved:
https://gyazo.com/30b9fc7e340a87c477ca49ebaedc9774
Here's how it behaves when I move:
https://gyazo.com/399cce0240b5ae97b39cd95dc247dbc9
Any ideas?
