Fishing system not tweening correctly

I’m making a fishing system similar to MeepCity’s, and when I try to tween the fish to a random position within a range (a part that spans the size of the lake), it snaps instead, and only sometimes moves smoothly.

-- localscript that handles the movement of the fish

local RS = game:GetService("ReplicatedStorage")
local TS = game:GetService("TweenService")

local rng = Random.new()

local spawnRE = RS:WaitForChild("SpawnFish")
local caughtRE = RS:WaitForChild("FishCaught")

local lakePart = game.Workspace:WaitForChild("LakePart")
local bubbles = script:WaitForChild("Bubbles")

local xRange = lakePart.Size.X * 0.5
local zRange = lakePart.Size.Z * 0.5

spawnRE.OnClientEvent:Connect(function(plr)
	local bubbleClone = bubbles:Clone()
	bubbleClone.Parent = game.Workspace
	bubbleClone.Position = lakePart.Position + Vector3.new(math.random(0 - xRange, xRange), 0, math.random(0 - zRange, zRange))
	
	while true do
		
		TS:Create(bubbleClone, TweenInfo.new(rng:NextInteger(0.3, 1)),
			{ Position = lakePart.Position + Vector3.new(math.random(0 - xRange, xRange), 0, math.random(0 - zRange, zRange))}
		):Play()
		
		wait(rng:NextInteger(1, 2))
	end
end)


(fish is the blue outline)

2 Likes

Is the event being fired more than once? Maybe there’s 2 loops overlapping one another somehow.

1 Like

just checked and no, its only fired once

1 Like

bump, cant figure this out

not sure but i dont think nextinteger return a 0.? value
(NOT sure thought, ive never had a chance to test out nextinteger in my code

(DECIMAL POINTS!!! NOT EXACTLY 0.???)

1 Like

i know math.random returns a number without decimals, and i think random.new:nextinteger() does. ive used it many times

1 Like

only way you can do is by doing math.random(1,10)/10 (thats a way to return 0.1 to 1)
and applies to nextintenger too i think

k. ill try it with one number instead of a random one and tell you if it works

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.