Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
-1
Answered by 5 years ago
Edited 5 years ago

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

0
The cutscene still seems to play for everyone in the server ;/ RagdoolTH12 2 — 5y
0
lemme see EmbeddedHorror 299 — 5y
0
try again now EmbeddedHorror 299 — 5y
0
so did it work? EmbeddedHorror 299 — 5y
View all comments (3 more)
0
Yes, thank you it worked. RagdoolTH12 2 — 5y
0
np EmbeddedHorror 299 — 5y
0
who downvoted EmbeddedHorror 299 — 5y
Ad

Answer this question