#preview item script very choppy

24 messages · Page 1 of 1 (latest)

quasi pelican
#

send me your code

#

@neon hemlock

neon hemlock
#

dm?

neon hemlock
quasi pelican
#

send it here

neon hemlock
#

for the local script it's this

#

local tool = script.Parent
local name = tostring(tool.Parent.Parent.Name).."'s Preview"
local preview2 = {0,0,0}

local function onequip()
local guy = tool.Parent
print(guy)
local mouse = game.Players.LocalPlayer:GetMouse().Hit.Position
local preview = Instance.new("Part",workspace)
preview.Position = mouse
preview.Name = tostring(name)
preview.CanCollide = false
preview.CanTouch = false
preview.Transparency = 0.2
preview.Anchored = true
preview.Size = Vector3.new(2,2,2)
print(preview.Name)
local run = game:GetService("RunService").Heartbeat
while task.wait(0.1) do
print("hi")
local mouse2 = game.Players.LocalPlayer:GetMouse()
local floatedposx = math.round(tonumber(mouse2.Hit.Position.X))
local floatedposy = math.round(tonumber(mouse2.Hit.Position.Y)) + preview.Size.Y /2
local floatedposz = math.round(tonumber(mouse2.Hit.Position.Z))
local surfaces = {preview.RightSurface, preview.BackSurface, preview.FrontSurface, preview.LeftSurface}
if mouse2.Target ~= preview then
preview.Position = Vector3.new(floatedposx,floatedposy,floatedposz)
preview2[1] = preview.Position.x
preview2[2] = preview.Position.y
preview2[3] = preview.Position.z

    end
end

end

local function ondequip()
local part = workspace:FindFirstChild(name)
part:Destroy()
end

tool.Equipped:Connect(onequip)
tool.Unequipped:Connect(ondequip)
tool.Activated:Connect(function()
local mouse2 = game.Players.LocalPlayer:GetMouse()
local remote = tool.connector
remote:FireServer(preview2)
end)

#

and the server script

#

local tool = script.Parent
local remote = tool.connector

remote.OnServerEvent:Connect(function(player,preview)
local part = Instance.new("Part", workspace)
part.Size = Vector3.new(2,2,2)
part.Position = Vector3.new(preview[1],preview[2],preview[3])
part.Anchored = true

end)

tool.Equipped:Connect(function()
tool.previewandposgetter.Enabled = true
end)

tool.Unequipped:Connect(function()
tool.previewandposgetter.Disabled = true
end)

quasi pelican
manic aurora
#

If you are saying make it smooth as I’m not having it go straight towards the camera

quasi pelican
#

why do you have a while wait in a render step?

manic aurora
#

Prolly make the raycsst ignore the preview part

#

Ok good luck bye bye

#

That’s how you fix the block going into the camera

quasi pelican
#

^thats a good suggestion

#

also remove the while wait in the render step

neon hemlock
#

will do

#

thank you guys

quasi pelican
#

instead do

RunService.Heartbeat:Connect(Function()
  --Code Here
end)
neon hemlock
#

thanks

eternal starBOT
#

studio** You are now Level 1! **studio

quasi pelican
#

this will run every frame