Function not functioning

I’m trying to make each function work, but nothing happens. I’m very confused. This is done in a LocalScript


local plr = game:GetService("Players").LocalPlayer
local UIS = game:GetService("UserInputService")
local Camera = game:GetService("Workspace").CurrentCamera
local Changer = script.Parent.Changer


local function CutsceneStarts()
	UIS.MouseIconEnabled = true
	Changer.Modal = true
	print("fin :D")
end

local function CutsceneEnds()
	UIS.MouseIconEnabled = false
	Changer.Modal = false
	print("fin :D")

end

game:GetService("Players").PlayerAdded:Connect(CutsceneStarts)
1 Like

Think of it like this. Since this is a local script, it is probably located in the player (whether that be the player instance itself or their character). Since it is located inside the player and you add a "PlayerAdded" event inside this script after the player is already created, nothing will happen. If you’re wanting the function to run as soon as the player is created, you can just:

local plr = game:GetService("Players").LocalPlayer
local UIS = game:GetService("UserInputService")
local Camera = game:GetService("Workspace").CurrentCamera
local Changer = script.Parent.Changer


local function CutsceneStarts()
	UIS.MouseIconEnabled = true
	Changer.Modal = true
	print("fin :D")
end

local function CutsceneEnds()
	UIS.MouseIconEnabled = false
	Changer.Modal = false
	print("fin :D")

end

CutsceneStarts()

If your not seeing anything at all in the output, maybe try changing up the way you are waiting for the character to load:

local Players = game:GetService("Players")
local Player = Players.LocalPlayer or Players.PlayerAdded:Wait()
CutsceneStarts()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.