so i have a part that when you click a button, its position moves + 17.84 studs on the Z axis. After a certain position on the Z axis, i want it to stop moving that direction. Here is the code i have currently.
local los = game.Workspace.LOS
local lmarker = game.Workspace.LOSmarker
local fd = game.Workspace.FD
local fmarker = game.Workspace.FDmarker
local button = script.Parent
button.MouseButton1Down:Connect(function()
los.Position = los.Position + Vector3.new(0,0,17.84)
lmarker.Position = lmarker.Position + Vector3.new(0,0,17.84)
end)
So as i said, heres what i want to achieve. After a certain position on the Z axis, i want it to stop moving that direction. Thanks.
here’s what i added, can you describe it more in depth please?
local los = game.Workspace.LOS
local lmarker = game.Workspace.LOSmarker
local fd = game.Workspace.FD
local fmarker = game.Workspace.FDmarker
local button = script.Parent
button.MouseButton1Down:Connect(function()
los.Position = los.Position + Vector3.new(0,0,17.84)
lmarker.Position = lmarker.Position + Vector3.new(0,0,17.84)
if los.Position >= Vector3.new(150.43, 1.079, 164.496)then
end
end)
A scalar is a vector component which describes amount. If we are checking the scalar for the Zed we would get it from its “Z” property. Remeber, the position is a vector data type.
You can create a local variable in its header scope to then be assigned to the event listener. From there it is simply calling the Disconnect() method to the variable we assigned to our event listener.