How would I make this smoother?

What can I do to make this more fluent? (basketball mypark playing script.)

court = script.Parent.Parent
spot1 = court.Spot1
spot2 = court.Spot2
playing = court.Playing

playing.Changed:Connect(function(play)
	if play == true then
		local ball = game.Lighting.Ball:Clone()
		court.theBall.Value = ball
		
		local plr1 = spot1.plrOn.Value
		court.Team1.plr1.Value = plr1
		plr1.PlayerGui.InGame.Value = true
		plr1.Backpack.Assets.Team.Value = spot1.Team.Value
		plr1.Backpack.Assets.OpponentTeam.Value = spot1.oTeam.Value

		local plr2 = spot2.plrOn.Value
		court.Team2.plr1.Value = plr2
		plr2.PlayerGui.InGame.Value = true
		plr2.Backpack.Assets.Team.Value = spot2.Team.Value
		plr2.Backpack.Assets.OpponentTeam.Value = spot2.oTeam.Value
		
		wait()
		plr1.Character.Torso.CFrame = court.Side1.CFrame + Vector3.new(0,2,0)
		plr2.Character.Torso.CFrame = court.Side2.CFrame + Vector3.new(0,2,0)

		wait(2)
		plr1.Character.Humanoid.PlatformStand = false
		plr1.Character.Torso.Anchored = false
		plr2.Character.Humanoid.PlatformStand = false
		plr2.Character.Torso.Anchored = false
		ball.Parent = workspace
		ball.Court.Value = court
		ball.Position = court.Side1.Position + Vector3.new(0,2,0)
		script.Parent.Parent.shotclock.Value = 24
		script.Parent.Parent.shotclock.run.Value = true
		--ball.Anchored = true
	end
end)

1 Like

You haven’t really provided much information to specifically address your issue, such as what needs to be smoother, what you’re doing with the code you put down, etc. Just pasting code into the forums usually won’t get you much feedback since people typically don’t want to bother trying to make sense of someone else’s script without any introduction or context.


That said, I think you’re asking how you can make an animation/movement smoother, and the answer to that is usually using the TweenService.

1 Like

The first thing I noticed is that you do not have variables for paths you are using multiple times. I would suggest adding more, such as for the player’s backpack and such. This will make your code much more readable and organized.

2 Likes