Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Cutscene Animation As a Touch Event?

I use the following code to trigger a cutscene animation as soon as a player joins the game:

local cams = workspace:WaitForChild("Cameras")
 
local cam = workspace.CurrentCamera
 
local tweenService = game:GetService("TweenService")
 
wait(5)
 
cam.CameraType = Enum.CameraType.Scriptable
 
 
for i, camPart in pairs(cams:GetChildren()) do
   
    local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
   
    local goal = {CFrame = cams[i].CFrame}
   
   
    local tweenToNextCamera = tweenService:Create(cam, tweenInfo, goal)
   
   
    tweenToNextCamera:Play()
   
    tweenToNextCamera.Completed:Wait()
   
end
 
cam.CameraType = Enum.CameraType.Custom

Is there any way to do the same function but instead it triggers when a player touches a block?

1 comment

0

u can use a remote event to tell the client to play it or you can just detect the hits on the server

1 answer

You can use RemoteEvents for this!

Server Sided Script, Child of the part:

local Event = EventPath:WaitForChild("EventNameHere") -- Remote Event
local CoolDown = 30 -- Seconds before enabling the cutscene again

script.Parent.Touched:Connect(function(Hit)
	if Debounce == true then
		Debounce = false
		if Hit.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(Hit.Parent) then
			Event:FireClient(game.Players:GetPlayerFromCharacter(Hit.Parent))
		end
		wait(CoolDown)
		Debounce = true
	end
end)

Client Sided Script:

local Event = EventPath:WaitForChild("EventNameHere") -- Remote Event

Event.OnClientEvent:Connect(function()
	local cams = workspace:WaitForChild("Cameras")
	local cam = workspace.CurrentCamera
	local tweenService = game:GetService("TweenService")
	wait(5)
	cam.CameraType = Enum.CameraType.Scriptable
	for i, camPart in pairs(cams:GetChildren()) do
		local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
		local goal = {CFrame = cams[i].CFrame}
		local tweenToNextCamera = tweenService:Create(cam, tweenInfo, goal)
		tweenToNextCamera:Play()
		tweenToNextCamera.Completed:Wait()
	end
	cam.CameraType = Enum.CameraType.Custom
end)

4 comments

0

Is Remote Event the part that is supposed to be stepped on?

0

Remote event is a remote event.

0

The server sided script is supposed to be a child of the part that is supposed to be stepped on. if you are not familiar with remote events: go to the roblox studio site here https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

0

Ah understood. I'm guessing I put the client sided in ServerScriptService. What should the event name consist of? Sorry, I have a lot to learn from this.

This discussion is preserved as it was. New answers, comments, and votes are closed.