local PlacementItem = nil
local PreviousItem = nil
local HoldingR = false
spawn(function()
while true do
game:GetService('RunService').RenderStepped:wait()
local Mouse = Player:GetMouse()
if PlacementItem ~= nil and PreviousItem == PlacementItem then -- Same item
local PlaceItem = Player.Character:FindFirstChild("Item") or PlacementItem:Clone()
Mouse.TargetFilter = PlaceItem
PlaceItem.Parent = Player.Character
local PIC = PlaceItem:GetChildren()
for i = 1,#PIC do
if PIC[i].Transparency ~= 1 then
PIC[i].Transparency = 0.5
PIC[i].CanCollide = false
end
end
if HoldingR == false then
PlaceItem:MoveTo(Mouse.Hit.Position)
elseif HoldingR == true then
PlaceItem:SetPrimaryPartCFrame(CFrame.new(PlaceItem.PrimaryPart.Position,Vector3.new(Mouse.Hit.Position.X,PlaceItem.PrimaryPart.Position.Y,Mouse.Hit.Position.Z)))
end
elseif PlacementItem ~= nil and PreviousItem ~= PlacementItem then -- Different Items
PreviousItem = PlacementItem
elseif PlacementItem == nil then
if Player.Character:FindFirstChild("Item") then
Player.Character:FindFirstChild("Item"):Destroy()
end
end
end
end)
Aight so I see nothing wrong with this code; however, sometimes my model collapses into one.
https://gyazo.com/188c817a4c99a8561f83c1d5936a960e.png Before spamming R
https://gyazo.com/bbbb25233286c23a24ce6c1858a2851a.png After spamming R
https://gyazo.com/cd9fb3f2653ad7450d92d7062cf056fa.gif Me spamming R in a GIF

1 comment
In your script, you have the following line: "Position,Vector3", try changing this to "Position + Vector3.new(...)", there is only one variable in the CFrame.new() event.