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

Why does my ball not move when a force is applied to it?

Asked by
tjtorin 172
5 years ago

I want to create a tool that makes a ball that goes in the direction of when the player clicked. When the player clicks it creates the ball but the ball does not go anywhere.

01-- Local
02local tool = script.Parent
03local RS = game:GetService("ReplicatedStorage")
04local createPartEvent = RS:WaitForChild("CreatePartEvent")
05 
06tool.Equipped:Connect(function(mouse)
07    mouse.Button1Down:Connect(function()
08        local ray = Ray.new(
09            tool.Tip.CFrame.p,                          
10            (mouse.Hit.p - tool.Tip.CFrame.p).unit * 300
11        )
12        local ignore = game:GetService("Players").LocalPlayer.Character
13        local hit, position = workspace:FindPartOnRay(ray, ignore, false, true)
14 
15        print(position)        
16        createPartEvent:FireServer(hit, position)
17    end)
18end)

01-- Server
02local RS = game:GetService("ReplicatedStorage")
03local createPartEvent = Instance.new("RemoteEvent")
04local tool = script.Parent
05createPartEvent.Parent = RS
06createPartEvent.Name = "CreatePartEvent"
07 
08createPartEvent.OnServerEvent:Connect(function(player, hit, position)
09    local ball = Instance.new("Part")
10    ball.Parent = workspace
11    ball.BrickColor = BrickColor.new("Bright red")
12    ball.Material = "Neon"
13    ball.Shape = "Ball"
14    ball.Transparency = .25
15    ball.Anchored = true
View all 25 lines...

1 answer

Log in to vote
1
Answered by 5 years ago

On your server script, line 15 says to anchor the ball. The ball won't move via force or velocity while it's anchored.

1ball.Anchored = false
Ad

Answer this question