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

Object moving hundreds studs away from where it's supposed to be why?

Asked by
DevingDev 346 Moderation Voter
6 years ago

This script makes a chosen part move to the position of the mouse at least it's supposed to that but isn't where the mouse is at all, the part is just hundreds of studs away from where it's supposed to be when you move your mouse around.

local script:

repeat wait() until game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local repStorage = game:GetService("ReplicatedStorage")
local serStorage = game:GetService("ServerStorage")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local char = player.Character

local function round(num)
    local number = math.floor(num * 1 + 0.5) / 1
    return number
end

local placing = false
local function place(object)

end

local object = workspace:FindFirstChild("Model")
local function startPlacing()
    if not placing then
        object:Clone()
        placing = true
    end
end
startPlacing()

local Gridsize = 2
game:GetService("RunService").RenderStepped:Connect(function()
    if mouse then
        if mouse.Target then
            if placing then
                local x,y,z = round(mouse.X)/Gridsize, mouse.Hit ,round(mouse.Y)/Gridsize
                mouse.TargetFilter = object
                object:SetPrimaryPartCFrame(CFrame.new(x, y, z))
            end
        end
    end
end)

0
This might have something to do with the fact that you are dividing your X and Z values by 2 (GridSize) as seen on Line 33. UgOsMiLy 1074 — 6y
0
well i don't know DevingDev 346 — 6y

Answer this question