I have put ‘print(“”)’ between ‘UIS.InputBegan’ and ‘if Input.KeyCode’ and it printed but when i put ‘print(“”)’ inside of ‘if Input.KeyCode’ nothing happens? I have also tried ‘Input.UserInputType’ but still nothing.
this is a very common issue and i’ve read it everytime.
from what i see, i assume you’re using a basic script. since you’re using Players.PlayerAdded.
UserInputService doesn’t fire InputBegan for normal scripts, because it’s for an entire server, and not a single player. so, you should move the UserInputService handler to a localscript inside StarterPlayerScripts.
If it’s a server script then you can’t access the UserInputService, if it’s a local script then you can’t access other player’s GUIs. Your LOCAL script should be something like this:
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
local TI = TweenInfo.new(0.75, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local MainGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui")
local SB64 = MainGui.SB64
local Dark = MainGui.Darkness
local Bright = MainGui.Brightness
local T1 = TS:Create(Dark, TI, {BackgroundTransparency = 1})
local T2 = TS:Create(Bright, TI, {BackgroundTransparency = 0})
local T3 = TS:Create(Bright, TI, {BackgroundTransparency = 1})
Bright.Visible = false
SB64.Visible = true
Dark.Visible = true
task.wait(1)
T1:Play()
-------------------
T1.Completed:Wait()
-------------------
Dark.Visible = false
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.ButtonStart then
Bright.Visible = true
T2:Play()
-------------------
T2.Completed:Wait()
-------------------
SB64.Visible = false
task.wait(1)
T3:Play()
-------------------
T3.Completed:Wait()
-------------------
Bright.Visible = false
end
end)
No! You need to place this LOCALscript in StarterPlayerScripts. So that each player has his own script and his own gui, since the server cannot access the UserInputService
Local scripts in StarterPlayerScripts will already run for each player that logs into your game, but locally so you would use just one Players.LocalPlayer instead of iterating over :GetPlayers()
If you modified anything from @3YbuKtOp’s script can you post your modified version? Were there any errors in the output? How did it fail? what were you expecting it to do?