script.Parent.MouseClick:Connect(function(player) if player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Money") then player.leaderstats.Money.Value = player.leaderstats.Money.Value + 1 script.Parent.MaxActivationDistance = 0 end end)
thats my code im trying to make it so once u click it destroys then clones in a random location
You can use the method :Clone(), :Destroy() and math.random for the position.
script.Parent.MouseClick:Connect(function(player) if player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Money") then player.leaderstats.Money.Value = player.leaderstats.Money.Value + 1 script.Parent.Parent:Clone().Position = Vector3.new(math.random(0, 100), 0, math.random(0, 100)) script.Parent.Parent:Destroy() --// Make sure you do this AFTER you clone the click detector. script.Parent.MaxActivationDistance = 0 end end)
I'm pretty sure the names of those things give out what they do and how you use them.
You also don't need to set the MaxActivationDistance to 0 if you're destroying the old one.
Just a thought.
You don't need to actually clone an object to move it to a new position. The following code does similar to what you ask but it just moves the original to the new position as if you've destroyed it.
Code:
local Self = script.Parent.Parent local DistanceToCloneTo = 60 script.Parent.MouseClick:Connect(function(player) if player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Money") then player.leaderstats.Money.Value = player.leaderstats.Money.Value + 1 local XPos = (math.random()*DistanceToCloneTo)-(math.random()*DistanceToCloneTo) local ZPos = (math.random()*DistanceToCloneTo)-(math.random()*DistanceToCloneTo) local YPos = 0 Self.Position = Vector3.new(XPos,YPos,ZPos) end end)
I think you need to add at the end something to connect clickdetected with RightMouseClick or something, I'm not sure, but you can try.