Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

script works with no keys needed to be pressed but doesnt when the keys do need to be pressed?

Asked by 7 years ago
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?

0
Try to use UserInputService instead. TheHospitalDev 1134 — 7y

Answer this question