You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want it to move to the mouse position and be rotated to where the player is facing. - What is the issue? Include screenshots / videos if possible!
The object constantly spins everytime I move my mouse.
function PreviewF(val)
local clone
if script.Parent.DigMode.Value ~= true and val ~= nil then
mouse.Move:Connect(function()
if clone == nil then
clone = val:Clone()
clone.Parent = game.Workspace
end
mouse.TargetFilter = clone
clone:MoveTo(mouse.Hit.Position)
local rotation = CFrame.Angles(0,math.rad(Player.Character.HumanoidRootPart.Orientation.Y),0)
local modelCFrame = clone:GetPrimaryPartCFrame()
clone:SetPrimaryPartCFrame( modelCFrame * rotation )
for i,v in pairs(clone:GetDescendants()) do
pcall(function()
v.Transparency = 0.5
v.CanColide = false
v.Anchored = true
end)
end
wait(0.1)
end)
mouse.Button1Down:Connect(function(opt)
if equipped == true then
script.Parent.Events.Dig:FireServer(mouse.Hit.p)
wait(clone.Configuration.BuildTime)
clone:Destroy()
end
end)
end
end
script.Parent.Events.ChangedVal.OnClientEvent:Connect(function(printthis)
PreviewF(printthis)
end)