I’m trying to make it so wherever the user of a tool clicks a part is released and goes to the direction of the person’s mouse however it doesn’t work?
server code
local player = game.Players.LocalPlayer
local tool = script.Parent
local event = tool:WaitForChild('Event')
event.OnServerEvent:Connect(function(player, mouseEvent)
print(player, mouseEvent)
--create the star when we click the mouse button:
local star = Instance.new("Part")
local starmesh = game.ReplicatedStorage.Starmesh:Clone()
local dmg = game.ReplicatedStorage["Damage Script"]:Clone()
star.Shape = Enum.PartType.Ball
star.BrickColor = BrickColor.new("Black")
star.Anchored = false
star.CanCollide = false
star.Massless = true
star.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-1)
star.CFrame = CFrame.new(star.Position, mouse.Hit.p) --make the star face the mouse position
star.Size = Vector3.new(2,2,2)
dmg.Parent = star
starmesh.Parent = star
--gravity is a nono
local antiGravity = Instance.new("BodyForce")
antiGravity.Force = Vector3.new(0, workspace.Gravity * star:GetMass(), 0)
antiGravity.Parent = star
--add star to workspace bSfore firing
star.Parent = workspace
star.Velocity = CFrame.new(player.Character.HumanoidRootPart.Position, mouse.Hit.p).lookVector * 100 -- change this number to a smaller number if you want the star to go slower
mouse = mouseEvent
end)
client code
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local tool = script.Parent
local event = tool:WaitForChild('Event')
event:FireServer(mouse.Hit)
Help would be appreciated thank you