-
What do you want to achieve? I would like to have a cutscene trigger for the player when they touch a certain part. There’s some other effects like a teleport and gui but those are secondary.
-
What is the issue? When the local player touches the part, it shows the cutscene for ALL players.
-
What solutions have you tried so far? I have tried checking for the humanoid and some other things I found in old devforum questions.
local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Point1 = workspace.cutscene.Point1
local Point2 = workspace.cutscene.Point2
local part = Point1
local Controller = require(game.Players.LocalPlayer:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule")):GetControls()
local function TweenCamera(Pos)
local TweenService = game:GetService("TweenService")
local TweenInf = TweenInfo.new(8, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local Tween = TweenService:Create(Camera, TweenInf, {CFrame = Pos})
Tween:Play()
end
local Player = game.Players.LocalPlayer
part.Touched:Connect(function(hit)
TweenCamera(Point2.CFrame)
Controller:Disable()
wait(3)
Player.Character:MoveTo(Vector3.new(-208.915, -32.232, -13.74))
game.StarterGui.facility.Enabled = true
wait(2)
Controller:Enable()
game.StarterGui.facility.Enabled = true
end)
I know a good amount of lua, but am not a master. This may be a very simple fix.
1 Like
I think it’s because the touch event recognizes hit as basically everything in the workspace.
I have a Gui very similar to this in which it checks for if the player had touched a part in order to open. Maybe add if hit.Parent == Character and Debounce == false then
after the touch event is fired.
Checking to see if what was hit was the character may prevent it from firing for everyone’s screen. Also, checking if Debounce is false and setting it to true right after essentially prevents the script from firing over and over again. Be sure to change it to true if you want the cutscene to play again afterwards.
Oh yeah and be sure to close that if statement and set Debounce to false at the start of the script.
Last thing, I’m under the assumption that the script happens to be a local one. LocalScripts can recognize if a player touches a part in the workspace. I don’t know how well this would work on camera-based cutscenes like yours, but it definitely worked for my situation.
Also, is there any reason Player is defined twice?
Anyways, I hope this all helps.
1 Like
Like mentioned earlier, .Touched
replicates across all clients, whenever any player touches the part, the animation will start regardless of which player touched it.
The Touched event should be in a regular script inside of the part. Whenever the part is touched, get the player from the part and fire a remote event to that player’s client, preferably a local script in StarterPlayerScripts. The client can then do the cutscene.
If you have the character, you can use an remote event (server to client this time) and game.Players:GetPlayerFromCharacter(char).