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

Using camera rotation and plaer position to move with block?

Asked by 7 years ago
Edited 7 years ago

HI in my game i want if i left mouse draging on part it follow my mouse 10 studs of player head and if i rotate with camera the object rotate too iam tryied all tutorial on wiki with

Player = script.Parent.Parent
mouse = Player:GetMouse()

function onKeyDown(key)
key = key:lower()
if key == "r" then 
local brick = Instance.new("Part", game.Workspace)
brick.Name = "NewBrick" 
brick.Size = Vector3.new(3,3,3) 
brick.Shape = ("Ball")
brick.CanCollide = false
brick.Position = Player.Character.Torso.Position + Player.Character.Torso.CFrame.lookVector*5
brick.TopSurface = "Smooth"
brick.BottomSurface = "Smooth"
Instance.new('Fire',brick)
brick.Transparency = 0.5
local bv = Instance.new("BodyVelocity")
bv.Parent = brick
bv.velocity = (mouse.Hit.p - Player.Character.Torso.Position).unit*50
end
end

mouse.KeyDown:connect(onKeyDown)

or

pt = game.Lighting.Part:Clone()
pt.Parent = game.Workspace.CurrentCamera

local plr = game.Players.LocalPlayer

Mouse = plr:GetMouse()
local prev_mousehit

klik = false

Mouse.Button1Up:connect(function()
    klik = false
end)

Mouse.Button1Down:connect(function()
    klik = true
end)

Mouse.Move:connect(function()
    if klik == true then
        if Mouse.Hit.p == prev_mousehit then
            pt.CFrame = CFrame.new(pt.Position, Vector3.new(Mouse.Hit.p.x,Mouse.Hit.p.y,Mouse.Hit.p.z))
            prev_mousehit = Mouse.Hit.p
        end
    end
end)


0
Line 21 on script #2, try ~= instead of == RubenKan 3615 — 7y
0
but this not workins scripts its only example i want fully working code honzapat_CZ -5 — 7y
0
This is not a request site. GoldenPhysics 474 — 7y

Answer this question