Attempt to index nil with character

So the title says it all. I’m make a game but this part script isn’t working It’s supposed to make a cutscene but however, the output, concerning the script just says:
“Attempt to index nil with Character”
Here’s the Part’s script:

local Part = script.Parent
local Door = script.Parent.Parent.Door
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Cutscene = Character.WaitForChild("Cutscene")
local TS = game:GetService("TweenService")--Forget that
local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out)--Forget that
local Properties = {Position = Vector3.new(965.44, 23.039, -0.87)}--Forget that
local Tween = TS:Create(Cutscene, tweenInfo, Properties)--Forget that

Part.Touched:Connect(function()
	Tween:Play()
	Door.CanCollide = true
end)

Please let me know about the errors I’ve placed :smiley:

2 Likes

If this is being done from a server script, the LocalPlayer can only be accessed from local scripts.

That will not work, since the Character is not a child of the player you will just be indefinitely yielding the thread.

Are you doing this from a local script (client) or a script (server)?

1 Like

Note that if you’re trying to do this from the server then “LocalPlayer” doesn’t really exist and so you will get the following error:

1 Like

It’s Character:WaitForChild(“Cutscene”) with a colon

You can’t access the localplayer from a server script(If you are doing this from a server script). You can only access the localplayer through a local script

@Ze_tsu
so how do I access Cutscene part of the player?

1 Like

You can either make the script client sided and use a local script

Or

You can fire a remote event when the player touches the part and then have a local script listen for when the client is fired. You will than have it play the tween and do whatever else you need to do on the client.

1 Like

If this is your error

Workspace.Script:3: attempt to index nil with ‘Character’

then it HAS to be because you did a script. You need what is called a LOCAL Script which is why your code isn’t running. I did a test run just to make sure and I got the EXACT same error so I am pretty sure that this is what is happening

You don’t even need to define the player.

For a touched event, you can use the GetPlayerFromCharacter and fire a remote event to a local script.