Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

This is not movingthe block, help?

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

✓ Accepted answer

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)

1 comment

0

This is succesfully working! Thanks for the help!

This discussion is preserved as it was. New answers, comments, and votes are closed.