This may be a little hard for me to describe, but I’ll try my best!
Basically, I’m working on a placement system for an item using the following code:
local PlacePhone = function()
if workspace:FindFirstChild(Player.Name.."Phone") == nil then
local Arrow = game.ReplicatedStorage.Arrow
local NewArrow= Arrow:Clone()
NewArrow.Parent = workspace
NewArrow.Name = Player.Name.."Phone"
else
local NewArrow = workspace:FindFirstChild(Player.Name.."Phone")
if (mouse.Hit.Position-Player.Character:WaitForChild("HumanoidRootPart").Position).Magnitude < 15 then
NewArrow.Color = Color3.new(0, 1, 0)
NewArrow.CFrame = mouse.Hit
Bad = false
print(NewArrow.Position)
else
NewArrow.Color = Color3.new(1, 0.00784314, 0.0235294)
NewArrow.CFrame = mouse.Hit
print("AHHHHHHH")
Bad = true
end
end
end
Where the variable “Bad” determines if it can be placed there or not.
When it is an acceptable spot, it prints the position of the phone.
This is connected via a function that binds it to a renderstep function when they click a UI button:
Player.PlayerGui.RoTokInterface.DanceChoice.Option.Options.Solo.MouseButton1Click:Connect(function()
RunService:BindToRenderStep("Phone Placement",1,PlacePhone)
Player.PlayerGui.RoTokInterface.DanceChoice.Option.Visible = false
end)
This all works the way it should. it’s the next function that acts a bit weird; the actual placement of the phone:
UIS.InputBegan:Connect(function(input, _gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 and Bad == false then
Bad = true
RunService:UnbindFromRenderStep("Phone Placement")
if workspace:FindFirstChild(Player.Name.."Phone") then
local position = workspace:FindFirstChild(Player.Name.."Phone").Position
print(position)
AngleCheck(position)
workspace:FindFirstChild(Player.Name.."Phone"):Destroy()
end
elseif input.UserInputType == Enum.UserInputType.MouseButton1 and Bad == true then
Notification("This location is too far away!",Color3.fromRGB(255,0,0))
end
end)
UIS being UserInputService. Ignore AngleCheck() and Notification().
When I get the position of the phone, it prints something around 27 studs (only on the Y coordinate ) below where it should be (See image, where print “1” is the print from the PlacePhone function and print “2” is from the UIS function)
any huge reason for this? I’m so confused lol, there are no other functions that connect or intercept with these 3.