I saw many games that a part was clickable without clickdetector and I don’t know why my script doesn’t work, I would like some help with this and I would really appreciate it. The script of mine is a Localscript inside the Part (Part52). The part’s name is “Part52” If you haven’t noticed.
And now I’m actually thinking that this isn’t possible
local TargetPart = game.Workspace:WaitForChild("Part52")
local Mouse = game.Players.LocalPlayer:GetMouse()
Mouse.Button1Down:Connect(function()
local Target = Mouse.Target
if Target == TargetPart then
print("Clicked!")
end
end)
The thing is I’m trying to make it work with like TweenService so that the part will move from one position to another here is the code I’m trying:
local TargetPart = game.workspace.Part52
local Mouse = game.Players.LocalPlayer:GetMouse()
local twservice = game:GetService("TweenService")
local part = game.workspace.Part52
local Properties = {
Position = Vector3.new(34.397, 11.052, 61.055)
}
local twinfo = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
local tween = twservice:Create(script.Parent,twinfo,Properties)
Mouse.Button1Down:Connect(function()
local Target = Mouse.Target
if Target == TargetPart then
tween:Play()
print("Clicked!")
end
end)
And here is the error code:
TweenService:Create no property named ‘Position’ for object 'PlayerGui
local tween = twservice:Create(script.Parent,twinfo,Properties) here you are trying to tween the PlayerGui(script.Parent) do local tween = twservice:Create(part ,twinfo,Properties)
Thats what you want I guess.
EDIT : I also suggest you to use UserInputService rather than Mouse events. reason : Reason