Basically, all the random coordinates are the places it can go to. When I click the TextButton though, the BodyPosition won't change and it doesn't move towards my destination. This is a script inside TextButton, which is in a ScreenGui, which is in StarterGui.
flickball = workspace.ball.BodyPosition.Position if script.Parent.MouseButton1Click:Connect(function() end) then balldestination = math Random (1,9) if balldestination == 1 then flickball = Vector3.new(-364.459, 12.823, -380.102) end if balldestination == 2 then flickball = Vector3.new(-364.459, 13.118, -384.488) end if balldestination == 3 then flickball = Vector3.new(-364.459, 13.118, -388.348) end if balldestination == 4 then flickball = Vector3.new(-364.459, 13.118, -393.201) end if balldestination == 5 then flickball = Vector3.new(-364.459, 12.823, -397.441) end if balldestination == 6 then flickball = Vector3.new(-364.459, 5.271, -380.281) end if balldestination == 7 then flickball = Vector3.new(-364.459, 5.395, -383.592) end if balldestination == 8 then flickball = Vector3.new(-364.459, 5.395, -393.201) end if balldestination == 9 then flickball = Vector3.new(-364.459, 5.271, -397.441) end end
You don't need if statement The function will run itself
Here is function
script.Parent.MouseButton1Click:Connect(function() end)
And you need RemoteEvent to change Value.
Insert RemoteEvent and normal script in local script.
Use FireServer and OnServerEvent.
Local Script
script.Parent.MouseButton1Click:Connect(function() script.RemoteEvent:FireServer(game.Players.LocalPlayer.Character) end)
Normal Script
local flickball = workspace.ball.BodyPosition script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr,char) balldestination = math Random (1,9) if balldestination == 1 then flickball.Position = Vector3.new(-364.459, 12.823, -380.102) end if balldestination == 2 then flickball.Position = Vector3.new(-364.459, 13.118, -384.488) end if balldestination == 3 then flickball.Position = Vector3.new(-364.459, 13.118, -388.348) end if balldestination == 4 then flickball.Position = Vector3.new(-364.459, 13.118, -393.201) end if balldestination == 5 then flickball.Position = Vector3.new(-364.459, 12.823, -397.441) end if balldestination == 6 then flickball.Position = Vector3.new(-364.459, 5.271, -380.281) end if balldestination == 7 then flickball.Position = Vector3.new(-364.459, 5.395, -383.592) end if balldestination == 8 then flickball.Position = Vector3.new(-364.459, 5.395, -393.201) end if balldestination == 9 then flickball.Position = Vector3.new(-364.459, 5.271, -397.441) end end)