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

How do I make this cutscene only play for the player who triggers it and not everyone in the game?

In my game, when a player steps on a certain part, it triggers a cutscene however I'd like it to only play for the player who steps on the part but instead the cutscene plays for everyone?

Cutscene trigger script:

-- localscript in starterGui
local db = false
local player = game.Players.LocalPlayer
local TweenService = game:GetService("TweenService")
local cam = workspace.CurrentCamera

local TouchPart = game.Workspace.MORPH.Head -- Change this to the part you want to be touched

function play(char)
wait(1)
if db == false then
db = true
    local PP = char.PrimaryPart
    cam.CameraType = Enum.CameraType.Scriptable

    local BCFrame = PP.CFrame * CFrame.new(0,0,-3) * CFrame.new(0,math.pi,10)
    local targetCFrame = PP.CFrame * CFrame.new(0, 0, -12) * CFrame.Angles(0, math.pi, 0)

    cam.CFrame = BCFrame 

    local tween = TweenService:Create(
        cam,
        TweenInfo.new(13),
        {CFrame = targetCFrame}
    )

    tween:Play()
    tween.Completed:Wait()
    cam.CameraType = Enum.CameraType.Custom
wait(10)
db = false


end
end

TouchPart.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then -- checking if the object that touched it is a player
        play(hit.Parent) -- plays the animation
    end
end)

-- This event below will run when the player is added. Delete it all if you do not want this!
player.CharacterAdded:Connect(function(character)
    wait(3)
    play(game.Players.LocalPlayer.Character)
end)

1 answer

✓ Accepted answer

Its obvious thats a free model, however, I will still help you. first things first. -make sure its a localscript -make sure its parented to startergui and NOT the part -make sure its not disabled



local db = false
local player = game.Players.LocalPlayer
local TweenService = game:GetService("TweenService")
local cam = workspace.CurrentCamera

local TouchPart = game.Workspace.MORPH.Head -- Change this to the part you want to be touched

function play(char)
wait(1)
warn("played")
if db == false then
db = true
    local PP = char.PrimaryPart
    cam.CameraType = Enum.CameraType.Scriptable

    local BCFrame = PP.CFrame * CFrame.new(0,0,-3) * CFrame.new(0,math.pi,10)
    local targetCFrame = PP.CFrame * CFrame.new(0, 0, -12) * CFrame.Angles(0, math.pi, 0)

    cam.CFrame = BCFrame 

    local tween = TweenService:Create(
        cam,
        TweenInfo.new(13),
        {CFrame = targetCFrame}
    )

    tween:Play()
    tween.Completed:Wait()
    cam.CameraType = Enum.CameraType.Custom
wait(10)
db = false

warn("finished")
end
end

TouchPart.Touched:Connect(function(hit)
warn("touched")
    if hit.Parent: FindFirstChild("Humanoid") then -- checking if the object that touched it is a player
local plr=game.Players:FindFirstChild(hit.Parent.Name) 
if plr then
if plr.Name==game.Players.LocalPlayer.Name then
        play(hit.Parent) -- plays the animation
end
end
    end
end)


mark as answer if helped or add a comment with the error if it didnt

7 comments

0

The cutscene still seems to play for everyone in the server ;/

0

lemme see

0

try again now

0

so did it work?

0

Yes, thank you it worked.

0

np

0

who downvoted

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