I tried this but it doesn't seem to work. Please help me!
script.Parent.ClickDetector.MouseClick:Connect(function()
script.Parent.Position = Vector3.new(1.781, 0.5, 35.84)
end)
I tried this but it doesn't seem to work. Please help me!
script.Parent.ClickDetector.MouseClick:Connect(function()
script.Parent.Position = Vector3.new(1.781, 0.5, 35.84)
end)
Put this in a server script and you're good to go.
It won't work. Then you would have to edit the script. Cause then the parent would be serverscriptservice.
You can put server scripts in other places besides serverscriptservice lol.
Everything works! Just make sure there is no weld.
I would recommend making a loop so it changes multiple times. Like this.
while wait() do
script.Parent.ClickDetector.MouseClick:Connect(function()
end)
end
Otherwise, everything is good!
Also, make sure the click detector exists and the script's parent is the part.
Sorry, what's the point of the infinite loop? So what changes multiple times?
You could just use CFrame for this, it's easier and more simple. This script needs to be put INSIDE the part.
As said by other users, please make sure there are no welds stopping it from moving.
Random Select Position:
local Positions = {
{1.781, 0.5, 35.84},
{1.6, 0.5, 35}
}
--[[
Made a table supposing it was RANDOM, I'll give another example of a precise CFrame.
]]
local function GetRandomPosition()
return Positions[math.random(1, #Positions)]
end
local function OnClick()
local Part = script.Parent
local CD = Part:WaitForChild("ClickDetector") -- checks if it has a clickdetector
Part.CFrame = CFrame.new(Vector3.new(GetRandomPosition()))
end
script.Parent:WaitForChild("ClickDetector").MouseClick:Connect(OnClick)
Specific Position:
local function OnClick()
local Part = script.Parent
local CD = Part:WaitForChild("ClickDetector") -- checks if it has a clickdetector
Part.CFrame = CFrame.new(Vector3.new(1.781, 0.5, 35.84)
end
script.Parent:WaitForChild("ClickDetector").MouseClick:Connect(OnClick)
lmk if this works, hope it does.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Is there a Weld in the part? Or something similar?
Yeah, thanks, didn't notice I had it lmao, now write that as an answer so that I can accept you