I want to create a basic tool which shoots things out depending on the name of it. However, at the moment, it teleports the part to the place a click and then moves. Rather than me click in the place and the projectile flying from my tool to that location..
Here's my code for my local script:
local Tool = script.Parent local toolTip = script.Parent.Handle Tool.Equipped:connect(function(Mouse) Mouse.Button1Down:connect(function() game.ReplicatedStorage.Powers:FireServer(Mouse.Hit, Tool.Handle) end) end)
My code from my server script:
game.ReplicatedStorage.Powers.OnServerEvent:Connect(function(player, MouseHit, Handle) print(player, MouseHit, Handle) if player.Spell.Value == "Water" then local S1 = Instance.new("Part",workspace) local S1b = Instance.new("BodyVelocity") S1.CFrame = MouseHit S1.Anchored = false S1.CanCollide = false S1.formFactor = "Symmetric" S1.Shape = "Ball" S1.Size = Vector3.new(1,1,1) S1.TopSurface = "Smooth" S1.BottomSurface = "Smooth" S1.Transparency = 0.5 S1.Elasticity = 1 S1.Friction = 0 S1.BrickColor = BrickColor.new("Bright blue") S1b.Velocity = (MouseHit.p - Handle.CFrame.p).Unit * 200 S1b.Velocity = (MouseHit.p - Handle.CFrame.p).Unit * 2 S1b.Parent = S1 game:GetService("Debris"):AddItem(S1, 2) end end)
Thank you.
try this , i'm not in studio so test it and let me know
game.ReplicatedStorage.Powers.OnServerEvent:Connect(function(player, MouseHit, Handle) print(player, MouseHit, Handle) if player.Spell.Value == "Water" then local S1 = Instance.new("Part",workspace) local S1b = Instance.new("BodyVelocity") S1.CFrame =Handle.CFrame + Handle.CFrame.lookVector*3 S1.Anchored = false S1.CanCollide = false S1.formFactor = "Symmetric" S1.Shape = "Ball" S1.Size = Vector3.new(1,1,1) S1.TopSurface = "Smooth" S1.BottomSurface = "Smooth" S1.Transparency = 0.5 S1.Elasticity = 1 S1.Friction = 0 S1.BrickColor = BrickColor.new("Bright blue") S1b.Velocity = MouseHit.lookVector*100 S1b.Parent = S1 game:GetService("Debris"):AddItem(S1, 2) end end)