I tried doing CFrame but it kept on going back to the original position
heres the model im using with a script as a base model
inside the script:
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local Up = TweenService:Create(script.Parent, TweenInfo.new(1), {Orientation = 90})
local Down = TweenService:Create(script.Parent, TweenInfo.new(1), {Orientation = 0})
local toggle = true
local Key = Enum.KeyCode.V
UserInputService.InputBegan:Connect(function(input, _gameProcessed)
if input.KeyCode == Key then
if toggle then
Down:Play()
toggle = false
else
Up:Play()
toggle = true
end
end
end)
i want the tween the orientation of X like if i do Down:play() it will set the orientation x to 0 and if i do up:play() it will set the orientation x to 90 not at the same time.
local part = part.here
local info = TweenInfo.new(1) --amount of seconds and easing styles
local targetDown = {part.Orientation = Vector3.new(0,0,0)}
local targetUp = {part.Orientation =Vector3.new(90,0,0)}
local tweenDown = game:GetService(“TweenService”):Create(part, info, targetDown)
local tweenUp = game:GetService(“TweenService”):Create(part, info, targetUp)
@Dede_4242 your code is wrong. You need to provide a dictionary containing all the properties needed to be tween in the last argument for the Create function.
You need to use weld and PrimaryPart for the model and you can’t use UserInputService in server scripts, you have to do it via local script and RemoteEvent
If I’m not wrong it’ll not, as Vector3 is a vector, to move you usually need CFrame
Also I just noticed I messed up everything so lemme edit the script
Please explain further
i welded all the parts to the primarypart
i made a local script wich works
local UserInputService = game:GetService("UserInputService")
local Key = Enum.KeyCode.V
local toggle = false
UserInputService.InputBegan:Connect(function(input, _gameProcessed)
if input.KeyCode == Key then
if toggle then
game.Workspace.Goggles.Toggle:FireServer('Down')
toggle = false
else
game.Workspace.Goggles.Toggle:FireServer('Up')
toggle = true
end
end
end)
but the tweening service still doesnt work
server script:
local TweenService = game:GetService("TweenService")
local part = script.Parent.PrimaryPart
local Up = TweenService:Create(part, TweenInfo.new(1), {Orientation = Vector3.new(90,part.Orientation.Y,part.Orientation.Z)})
local Down = TweenService:Create(part, TweenInfo.new(1), {Orientation = Vector3.new(0,part.Orientation.Y,part.Orientation.Z)})
script.Parent.Toggle.OnServerEvent:Connect(function(plr, toggle)
if toggle == 'Up' then
Up:Play()
else
Down:Play()
end
end)
Try this, if it works, but in the wrong direction - just adjust for yourself
local Up = TweenService:Create(part, TweenInfo.new(1), {CFrame = part.CFrame*CFrame.Angles(math.rad(90), 0, 0)})
local Down = TweenService:Create(part, TweenInfo.new(1), {CFrame = part.CFrame*CFrame.Angles(0, 0, 0)})
here oh and i forgot make a local script and put is in starterplayer script:
local UserInputService = game:GetService("UserInputService")
local Key = Enum.KeyCode.V
local toggle = false
UserInputService.InputBegan:Connect(function(input, _gameProcessed)
if input.KeyCode == Key then
if toggle then
game.Workspace.Goggles.Toggle:FireServer('Down')
toggle = false
else
game.Workspace.Goggles.Toggle:FireServer('Up')
toggle = true
end
end
end)