So in my fishing game my bober will go in the water and when its in the water if I click to take it out of the water that works but while it's in the water nothing happens like its suppose to but I'm not getting any errors..

So I'm unsure about which part of the script is causing the issue or not working correctly..

local bin = script.Parent
local player = script.Parent.Parent.Parent
local height = -.8
local underTime = 1.5
local halt = false
local angle = 0
local state = "up"
local P = game.Lighting.Rod.Ball:clone()
P.Ball1.Anchored = false
P.Ball2.Anchored = false
P.Ball1.CanCollide = true
local B = Instance.new("BodyPosition")
B.Name = "Vpos"
B.position = Vector3.new(0,height,0)
B.maxForce = Vector3.new(0,800,0)
--B.Parent = P.Ball1
local H = Instance.new("Hint")
local g = nil
local p = nil
local catchMode = 0
local ws = 0
local AAA = nil

function Err(error)
	H.Parent = player
	H.Text = error
	print(error)
end

function onButton1Down(mouse)
	if halt then return end
	halt = true
--	mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
	if state == "down" then
		player.Character.Humanoid.WalkSpeed = ws
		state = "up"
		if p ~= nil and p:findFirstChild("Ball1") then
			p.Ball1.Anchored = true
		end
		local F = 0
		if catchMode == 1 then
			local f = math.random(1,10)
			if f == 1 then F = 4 elseif f == 2 or f == 3 then F = 3 elseif f == 4 or f == 5 or f == 6 then F = 2 elseif f == 7 or f == 8 or f == 9 or f == 10 then F = 1 end
			print(tostring(F))
			if F ~= 0 then
				local mesh = script.Parent:findFirstChild("Mesh" .. tostring(F))
				if mesh ~= nil and p ~= nil then
					local ppp = Instance.new("Part")
					ppp.Size = Vector3.new(1,1.2,1)
					ppp.CFrame = p.Ball1.CFrame - Vector3.new(0,2,0)
					ppp.CanCollide = false
					mesh:clone().Parent = ppp
					ppp.Parent = player.Character
					local w = Instance.new("Weld")
					w.C0 = CFrame.new(0,-2,0)
					if F == 2 then
						w.C0 = w.C0 * CFrame.fromEulerAnglesXYZ(math.pi/2,0,0)
					elseif F == 3 or F == 4 then
						w.C0 = w.C0 * CFrame.fromEulerAnglesXYZ(math.pi,0,0)
					elseif F == 1 then
						w.C0 = w.C0 * CFrame.fromEulerAnglesXYZ(math.pi/2,math.pi/2,0)
					end
					w.Part0 = p.Ball1
					w.Part1 = ppp
					w.Parent = w.Part0
				end
			end
		end
		if p ~= nil and p:findFirstChild("Ball1") then
			p.Ball1.Anchored = false
		end
		angle = math.pi/4*3
		wait(.5)
		if p ~= nil and p:findFirstChild("Ball1") then 
			p.Ball1.Vpos.position = g.Ball.Ball1.Position
			p.Ball1.Vpos.maxForce = Vector3.new(100,1200,100)
		end
		wait(.5)
		if p ~= nil then p:remove() end
		g.Ball.Ball1.Transparency = 0
		for i = 1, F do
			local pl = game.Workspace.PlayerProfiles:FindFirstChild(player.Name)
			local t = game.Workspace.PlayerProfiles:FindFirstChild(player.Name).Treasure
			if t ~= nil then
				local m = pl:findFirstChild("MaxMoney")
				if m ~= nil then
					if t.Value < m.Value then
						t.Value = t.Value + 1
					end
				end
			end
		end
		local Sq = game.Workspace.PlayerProfiles:FindFirstChild(player.Name):findFirstChild("Squids")
		if Sq ~= nil and F == 4 then
			Sq.Value = Sq.Value + 1
		end
		angle = math.pi/2
		wait()
		if AAA ~= nil then
			AAA.Parent = player.Character
			AAA = nil
		end
		wait(.5)
	elseif state == "up" then
		AAA = player.Character:findFirstChild("Animate")
		if AAA ~= nil then AAA.Parent = nil end
		ws = player.Character.Humanoid.WalkSpeed
		player.Character.Humanoid.WalkSpeed = 0
		state = "down"
		angle = math.pi/4
		wait(.2)
		p = g.Ball:clone()
		P.Ball1.Anchored = false
		P.Ball2.Anchored = false
		P.Ball1.CanCollide = true
		p.Parent = player.Character
		local w = Instance.new("Weld")
		w.C0 = CFrame.new(0,-0.01,0)
		w.Part0 = p.Ball1
		w.Part1 = p.Ball2
		w.Parent = w.Part0
		p.Ball1.CFrame = g.Ball.Ball1.CFrame
		B:clone().Parent = p.Ball1
		p.Ball1.Vpos.position = Vector3.new(0,height,0)
		g.Ball.Ball1.Transparency = 1
--		p.Vpos.position = g.Ball.Position
		wait(1)
		halt = false
		wait(1)
		while state == "down" do
			wait(1)
			if p and p:findFirstChild("Ball1") then
				if p.Ball1.Position.y > (height - 0.1) and p.Ball1.Position.y < (height + 0.1) then
					if math.random(1,14) == 12 then
						p.Ball1.Vpos.position = Vector3.new(0,height-0.6,0)
						catchMode = 1
						wait(underTime)
						catchMode = 0
						if p ~= nil and p:findFirstChild("Ball1") then
							p.Ball1.Vpos.position = Vector3.new(0,height,0)
						else
							break
						end
					end
				end
			end
		end
--		if p ~= nil then p.Ball1.Vpos.position = P.Ball1.Vpos.position end
	end
	wait(.1)
--	wait(2)
	halt = false
--	mouse.Icon = "rbxasset://textures\\GunCursor.png"
end

function onSelected(mouse)
	state = "up"
	angle = math.pi/2
	g = game.Lighting.Rod:clone()
	g.Parent = player.Character
	local C = g:GetChildren()
	for i=1, #C do
		if C[i].className == "Part" then
			local W = Instance.new("Weld")
			W.Part0 = g.Middle
			W.Part1 = C[i]
			local CJ = CFrame.new(g.Middle.Position)
			local C0 = g.Middle.CFrame:inverse()*CJ
			local C1 = C[i].CFrame:inverse()*CJ
			W.C0 = C0
			W.C1 = C1
			W.Parent = g.Middle
		elseif C[i].className == "Model" then
			for _, i in ipairs(C[i]:GetChildren()) do
				if i.className == "Part" then
					local W = Instance.new("Weld")
					W.Part0 = g.Middle
					W.Part1 = i
					local CJ = CFrame.new(g.Middle.Position)
					local C0 = g.Middle.CFrame:inverse()*CJ
					local C1 = i.CFrame:inverse()*CJ
					W.C0 = C0
					W.C1 = C1
					W.Parent = g.Middle
				end
			end
		end
		local Y = Instance.new("Weld")
		Y.Part0 = player.Character["Right Arm"]
		Y.Part1 = g.Middle
		Y.C0 = CFrame.new(0, 0, 0)
		Y.Parent = Y.Part0
	end
	local h = g:GetChildren()
	for i = 1, #h do
		if h[i].className == "Part" then
			h[i].Anchored = false
			h[i].CanCollide = false
		elseif h[i].className == "Model" then
			for _, i in ipairs(h[i]:GetChildren()) do
				if i.className == "Part" then
					i.Anchored = false
					i.CanCollide = false
				end
			end
		end
	end
--	mouse.Icon = "rbxasset://textures\\GunCursor.png"
--	mouse.Button1Down:connect(function() onButton1Down(mouse) end)
	selected = true
	g.Ball.Ball1.Changed:connect(function()
		if g ~= nil and g:findFirstChild("Ball") ~= nil then g.Ball.Ball2.Transparency = g.Ball.Ball1.Transparency end
	end)
	while selected do
		player.Character.Torso["Right Shoulder"].DesiredAngle = angle
		wait()
	end
end

bin.Activated:connect(function() onButton1Down(nil) end)
bin.Equipped:connect(onSelected)
bin.Unequipped:connect(function()
	if p ~= nil then p:remove() end
	p = nil
	H.Parent = nil
	selected = false
	if g ~= nil then g:remove() end
	g = nil
	if state == "down" then
		player.Character.Humanoid.WalkSpeed = ws
	end
	if AAA ~= nil then
		AAA.Parent = player.Character
		AAA = nil
	end
	repeat
		if player.Character:findFirstChild("Rod") and player.Character.Rod:IsA("Model") then
			player.Character.Rod:remove()
		end
		wait()
	until not player.Character:findFirstChild("Rod")
end)

2 comments

0

We don't have the time to search through 242 lines of code. Try debugging it, by setting up a print() every few lines, then seeing where it stops.

0

ah okay thanks