Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Setting Player's position by mouse shows abnormal values when printed. Why?

Asked by
hallmk7 50
4 years ago

Hello everyone! I am working with somewhat teleknesis script which changes other player's position as the initial player drags his/her mouse but it shows abnormal values. This is what i have scripted till now:-

local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local uis = game:GetService("UserInputService")
local mouse = player:GetMouse()
local attachedToPlayer = false
local GotTarget = false
local Target = nil
local toggleOfUIS = false

mouse.Move:Connect(function()
    if toggleOfUIS == false then
        if mouse.Target.Parent:FindFirstChild("Humanoid") then
            Target = mouse.Target
            GotTarget = true
        else
            Target = nil
        end
    else
end
end)

uis.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.T then
        if toggleOfUIS == false then
            toggleOfUIS = true
            if GotTarget == true then
                attachedToPlayer = true
                repeat Target.Parent.HumanoidRootPart.Position = Target.Parent.HumanoidRootPart.Position + Vector3.new(mouse.X, mouse.Y, 0)
                wait(0.3)
                until toggleOfUIS == false or attachedToPlayer == false
                print(Target.Position)
                end
            elseif toggleOfUIS == true then
            toggleOfUIS = false
            attachedToPlayer = false
            end
        end
    end)

Please someone help!!

0
What are the abnormal values zboi082007 270 — 4y
0
like 1245.40845, -105.488304, -2753.35767 hallmk7 50 — 4y
0
Because it is printing the the mouse position (2d) converted into a 3d plane TheDeepH4x0r 20 — 4y

Answer this question