user = game.Players.LocalPlayer

players = game.Players:GetChildren()

local sound = Instance.new("Sound",workspace)
sound.SoundId = "http://www.roblox.com/asset?id=276146955"
sound.Volume = 10
sound.Pitch = 1
sound:Play()

wait(2.1)

for i,v in pairs(players) do
	if v:IsA("Player") then
		if v.Name ~= user.Name then
			char = v.Character
			for i,v in pairs(char:GetChildren()) do
				if v:IsA("Part") and v.Name ~= "HumanoidRootPart" then
					v.Anchored = true
				end
			end
		end
	end
end
for i = 1,25 do
	game.Lighting.TimeOfDay = 8
	wait()
	game.Lighting.TimeOfDay = 0
	wait()
end
game.Lighting.TimeOfDay = 0
wait(9)
for i,v in pairs(players) do
	if v:IsA("Player") then
		if v.Name ~= user.Name then
			char = v.Character
			for i,v in pairs(char:GetChildren()) do
				if v:IsA("Part") and v.Name ~= "HumanoidRootPart" then
					v.Anchored = false
				end
			end
		end
	end
end
game.Lighting.TimeOfDay = 13

this is the script where u dont have to press a key and it executes automatically

it changes it to night and then it goes back to day

but with this one it stop times and everyone cant move, then after the wait is up everyone can move but the timeofday doesnt go back to day

function onKeyPress(actionName, userInputState, inputObject)
user = game.Players.LocalPlayer

players = game.Players:GetChildren()

local sound = Instance.new("Sound",workspace)
sound.SoundId = "http://www.roblox.com/asset?id=276146955"
sound.Volume = 10
sound.Pitch = 1
sound:Play()

wait(2.1)

for i,v in pairs(players) do
	if v:IsA("Player") then
		if v.Name ~= user.Name then
			char = v.Character
			for i,v in pairs(char:GetChildren()) do
				if v:IsA("Part") and v.Name ~= "HumanoidRootPart" then
					v.Anchored = true
				end
			end
		end
	end
end
for i = 1,25 do
	game.Lighting.TimeOfDay = 8
	wait()
	game.Lighting.TimeOfDay = 0
	wait()
end
game.Lighting.TimeOfDay = 0
wait(9)
for i,v in pairs(players) do
	if v:IsA("Player") then
		if v.Name ~= user.Name then
			char = v.Character
			for i,v in pairs(char:GetChildren()) do
				if v:IsA("Part") and v.Name ~= "HumanoidRootPart" then
					v.Anchored = false
				end
			end
		end
	end
end
end
game.Lighting.TimeOfDay = 13
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.P)

help?

1 comment

0

Try to use UserInputService instead.