What is supposed to happen:It drops on my mouse’s hit poition
What it does: It does not change the position at all despite the fact that I made it change it
Hierarchy:
script.Parent.Activated:Connect(function()
if script.Parent.Value.Value==false then
local mou = game.Players.LocalPlayer:GetMouse()
if mou.Target:FindFirstChild("Item") then
local e =mou.Target
local fac=true
script.Parent.RemoteEvent:FireServer(e,fac)
end
end
if script.Parent.Value.Value==true then
print('ok')
local mou = game.Players.LocalPlayer:GetMouse()
print(mou.Target.Name)
if mou.Target.Name=="Drop" then
print('ye')
local e = script.Parent.Handle
local fac=false
local pos=mou.Hit.p
print(tostring(pos).."local")
script.Parent.RemoteEvent:FireServer(e,fac,pos)
end
end
end)
Script:
script.Parent.RemoteEvent.OnServerEvent:Connect(function(p,e,fac,pos)
if fac==true then
local d = e:Clone()
script.Parent.Name=e.Name
e:Destroy()
d.Name="Handle"
d.Item:Destroy()
d.Parent = script.Parent
script.Parent.Value.Value = true
script.Parent.Parent = game.Players[script.Parent.Parent.Name].Backpack
elseif fac==false then
e.Parent = game.Workspace
print(pos)
e.Position = pos
e.Name = script.Parent.Name
e.CanCollide = true
local f=Instance.new("BoolValue",e)
f.Name="Item"
script.Parent.Name="Grab"
script.Parent.Value.Value=false
script.Parent.Parent = game.Players[script.Parent.Parent.Name].Backpack
end
end)
I think you can try replacing print(pos) with wait() as the tool may still try to be locking the position. If that doesn’t work, you can try making a clone of the part like you did when you picked it up.
I added this bit of code repeat e.Position = pos until e.Position== pos and it just crashes the game, and I bet using wait() will make an infinite yield, which means e’s position can’t be set at all? why is this?
Firstly, a boolean can be only true or false so using an additonal if statement or elseif is irrelevant:
if script.Parent.Value.Value then
...
else
...
end
Also, try not to name instances the same as properties as Value.Value can get confusing.
I tried your code in studio and a part’s position gets set. The issue is probably to do with the part you are moving / dropping onto. Try printing the part’s new position after it is moved and finding out where it went?
If you want to prevent that delay on the user’s screen you can set the position on the client using the same code and once the server sets it again it will replicate to the client: