local tool = script.Parent local player = game:GetService("Players").LocalPlayer local Mouse = player:GetMouse() Debounce = false pressed = false cancelled = false canPress = false tool.Equipped:connect(function(mouse) print("Tool equipped!") mouse.Button1Down:connect(function() print("Mouse pressed!") if Debounce == false then Debounce = true local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 30) local part, position = workspace:FindPartOnRay(ray, player.Character, false, true) PreviewPart = script.Parent.Wooden_Floor:Clone() PreviewPart.Name = "Preview part" PreviewPart.Transparency = 0.5 PreviewPart.Anchored = true PreviewPart.CanCollide = false PreviewPart.Position = position + Vector3.new(0, 0.375, 0)-- + Vector3.new(0,part.Size.Y/2,0) PreviewPart.Parent = workspace customBuild = Instance.new("Part") customBuild.Transparency = 1 customBuild.Anchored = true customBuild.CanCollide = false customBuild.Name = "CustomBuild" customBuild.Parent = PreviewPart wait(1) canPress = true end end) end) while wait() do if Debounce == true then Mouse.Button1Down:connect(function() if canPress == true then pressed = true end end) Mouse.Button2Down:connect(function() if canPress == true then cancelled = true end end) if cancelled == true then Debounce = false cancelled = false pressed = false canPress = false for i,v in pairs(workspace:GetChildren()) do if v.Name == "Preview part" then v:Destroy() end end print(cancelled) elseif pressed == true then Debounce = false cancelled = false pressed = false canPress = false for i,v in pairs(workspace:GetChildren()) do if v.Name == "Preview part" then v.Transparency = 0 v.Name = "Floor" v.CanCollide = true end end end if PreviewPart ~= nil then local list = {player.Character,PreviewPart} local Player = game.Players:GetPlayers() local mouse = player:GetMouse() local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 30) local part, position = workspace:FindPartOnRayWithIgnoreList(ray, {player.Character,PreviewPart}, false, true) PreviewPart.Position = position --+ Vector3.new(0, 0.375, 0) end end end
It gives no error (client) it works inside studio fine, the tool is inside replicatedstorage cloned and then putted inside the player, it doesn't go to your mouse position inside a real server, other parts work find.