the whole thing works i just need help making it look better.
i made a system where when a player moves there mouse over a text label on there screen it changes the orientation of a brick in workspace.
i want to change just the orientation of the part using tweening instead of rotating it since rotating it looks choppy.
this is the script:
local brick = game.Workspace.CameraPart
script.Parent.MouseEnter:Connect(function()
if brick.Orientation == Vector3.new(0, -60, 0) then
brick.Orientation = Vector3.new(0, -90, 0)
elseif brick.Orientation == Vector3.new(0, -90, 0) then
brick.Orientation = Vector3.new(0, -120, 0)
end
end)
i dont know how to tween the parts orientation or anything about tweening and my goal is to build this sytem and not so much to learn so please be as clear on complex subjects etc and provide full scripts instead of reffering to how i would make those scripts.
1 Like
local TweenService = game:GetService("TweenService")
script.Parent.MouseHoverEnter:Connect(function()
-- Debounce needed, may make wierd spin
if brick.Orientation == Vector3.new(0, -60, 0) then
TweenService:Create(brick, TweenInfo.new(2.5), {Orientation = Vector3.new(0, -90, 0)}):Play()
elseif brick.Orientation == Vector3.new(0, -90, 0) then
TweenService:Create(brick, TweenInfo.new(2.5), {Orientation = Vector3.new(0, -120, 0)}):Play()
end
end)
1 Like
lemme see if it works thanks by the way
1 Like
I hope this code will help you. (TESTED)
-- This will be a loop.
local brick = game.Workspace.CameraPart
local TweenService = game:GetService("TweenService")
deb = -1
if brick.Orientation == Vector3.new(0, -60, 0) then
deb = 0
elseif brick.Orientation == Vector3.new(0, -90, 0) then
deb = 1
end
script.Parent.MouseEnter:Connect(function()
local timefortween = 1 -- You can change here.
if deb == 0 then
deb = 1
TweenService:Create(brick, TweenInfo.new(timefortween), {Orientation = Vector3.new(0, -90, 0)}):Play()
elseif deb == 1 then
deb = 0
TweenService:Create(brick, TweenInfo.new(timefortween), {Orientation = Vector3.new(0, -120, 0)}):Play()
end
end)
I suggest you to read this article.
https://developer.roblox.com/en-us/api-reference/class/TweenService
1 Like