Im trying to make the tween/camera in this script touch a Part so that an event will trigger, making 2 textbuttons visible.
local Camera = workspace.CurrentCamera
local Views = workspace:WaitForChild("Views2")
local tweenService = game:GetService("TweenService")
local UIS = game:GetService("UserInputService")
local Right = game.StarterGui.View.ViewRight
local Main = game.StarterGui.View.MainView
local Part = game.Workspace.Hit
function tweenCamera(pos,tweenTime)
local result = tweenService:Create(Camera,TweenInfo.new(tweenTime,Enum.EasingStyle.Linear), {CFrame = pos.CFrame})
return result
end
local result = tweenCamera(Views.ViewRight, 9)
UIS.InputBegan:Connect(function(input)
if input.KeyCode==Enum.KeyCode.W then
result:Play()
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode==Enum.KeyCode.W then
result:Pause()
end
end)
Part.GetTouchingParts:Connect(function()
if Part.Touched then
Right.Visible = true
Main.Visible = true
end
end)
I tried to use GetTouchingParts:() to detect the part inorder to trigger the event, but it doesn’t seem to work.
Can someone explain to me if there are any errors in the script, and how I would be able to fix it? Thanks.
Touched is “an event only fires as a result of physics movement, so it will not fire if the CFrame property was changed such that the part overlaps another part. This also means that at least one of the parts involved must not be BasePart.Anchored at the time of the collision.”
Tween.Completed:Connect(function(playbackState)
if playbackState == Enum.PlaybackState.Completed then
Right.Visible = true
Main.Visible = true
end
end)
local PartsInPart = workspace:GetPartsInPart(Part)
for i, part in pairs(PartsInPart) do
if part.Name == "whatever the name is" then
Right.Visible = true
Main.Visible = true
end
end