Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make my boat not go above a certain Y position (on land)?

I am trying to make my boat not just be able to fly on land and so far I have not had any luck.

That is what I tried but my boat no longer turned and spazzed out...

script.Parent.PrimaryPart = script.Parent.Bottom

ModelCFrame = script.Parent.PrimaryPart 

while wait() do
	local x = script.Parent.Bottom.CFrame.X
	local z = script.Parent.Bottom.CFrame.Z

	script.Parent:SetPrimaryPartCFrame(CFrame.new(x, -11.470724105835, z))
end

If you know how to fix this or of an easier way I would appreciate it!

6 comments

0

I would suggest instead removing the ability to elevate the boat, if you're going to just counteract it with another script.

0

make an inviible transparent block in the air that subtracts the boat's y pos on impact

0

@MezornoIV - I am not changing the position with my boat script I am using velocity, what would I do to stop that?

0

@DominusInfinitus - It is a model so how would I make it subtract from a CFrame?

0

well the reason for this is that you are also resetting the rotation matrix of the CFrame

0

@theking48989987 - how would I not reset it?

1 answer

i have made something similar; its a jump limit for humanoids to prevent exploiters from fly hacking;

place in StarterPack:

local debounce = false

local root = nil

game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
	wait(.1)
	root = char:FindFirstChild("HumanoidRootPart")
end)

repeat wait(.1) until root ~= nil

game:GetService("RunService").RenderStepped:Connect(function()
	local rootPos = root.Position
	
	if rootPos.Y > 5 and debounce == false then
		debounce = true
		
		print("lol")
		
		local dir = root.CFrame.LookVector
		
		root.Anchored = true
		
		root.CFrame = CFrame.new(rootPos.X, 5, rootPos.Z) * CFrame.Angles(0, -math.asin(dir.X), 0)
		
		root.Anchored = false
		
		wait(.5)
		debounce = false
	end
end)

its practically what u did, except i saved the baseParts lookvector such that it can recover its original angle and hopefully solve ur problem.

4 comments

0

its kinda glitchy tho sometimes

0

@TheluaBanana - My script has the same problem as yours, the rotation changes. Know how to fix it?

0

well kinda

0

i have a few ideas in mind ill go try them out when i have the time

This discussion is preserved as it was. New answers, comments, and votes are closed.