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

This is not movingthe block, help?

Asked by 9 years ago

I tried to do a block that moves when i click somewhere. When i click, a block appears, but in the 0, 0, 0 position..

The code

local PL = game.Players.LocalPlayer
local MS = PL:GetMouse()
local RC = game.ServerStorage.Used_Parts.MovableRedCube
function Move()
    local RB = RC:Clone()
    RB.Position = Vector3.new(MS.Hit)
    RB.Parent = workspace
end

MS.Button1Up:connect(Move)

1 answer

Log in to vote
0
Answered by
ItsMeKlc 235 Moderation Voter
9 years ago

First off if this is in a Local Script (which it should be) this will not work on servers. So you should move the MovableRedCube to replicated storage or something else. Anyways try this:

local PL = game.Players.LocalPlayer
local MS = PL:GetMouse()
local RC = game.ReplicatedStorage.Used_Parts.MovableRedCube
function Move()
    local RB = RC:Clone()
    RB.Parent = workspace
    RB.CFrame = CFrame.new(MS.Hit.p)

end

MS.Button1Up:connect(Move)

0
This is succesfully working! Thanks for the help! loulou1112 35 — 9y
Ad

Answer this question