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

How can I make this script sit you down, wait 5 seconds, let you get up?

Asked by 4 years ago

When the player comes in contact with the brick, he will have 3 seconds to climb the obstacle. If he doesn't make it in time, his player will sit down and fall. However, once he falls down he can get up and climb again. How can I make this so that the player sits down, then has to wait 5 seconds before getting up.

Also, another thing if possible make the script work once every 30 seconds because if the player moves inside the brick, it makes the script run 3 times instead of one and he keeps sitting over and over.

function OnTouched(part)    
    local humanoid = part.Parent:FindFirstChild("Humanoid") 
    print("3 SECONDS LEFT TO DO WARPED WALL")
    wait(1)
    print("2 SECONDS LEFT TO DO WARPED WALL")
    wait(1)
    print("1 SECONDS LEFT TO DO WARPED WALL")
    wait(1)
    print("You've failed!")
    wait (0)    
    if (humanoid ~= nil) then
    humanoid.Sit = true
    end
end

script.Parent.Touched:connect(OnTouched)    

0
From what I know and have tried. You cannot force the human to not jump even if you remove the control module. The only way I know is... Put a sea at the player so that he sits in it and then make the Jump Power to 0. Works every time. ???? bostaffmanbulgaria1 89 — 4y

2 answers

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago
local ClimbTime = 3
local StandTime = 5

local function StartedClimbing(Climbing)
    local Humanoid = Climbing.Parent:FindFirstChildOfClass("Humanoid") 
    if (Humanoid) then wait(ClimbTime)
        if (Humanoid:GetState() == Enum.HumanoidStateType.Climbing) then
            Humanoid.PlatformStand = true
            wait(StandTime)
            Humanoid.PlatformStand = false
        end
    end
end

script.Parent.Touched:Connect(StartedClimbing)    
0
This will give you the basis code you desire. I am unsure how to assist you with time. I however suggest diving into tick(). Ziffixture 6913 — 4y
0
I'm not sure is this true, but I think PlatformStand is deprecated. Block_manvn 395 — 4y
0
It's not. Ziffixture 6913 — 4y
0
Thanks a lot! I showed this to a friend of mine who wasn't on at the time and he used your script, edited it and got it working for me. Sorry I didn't make my request clear enough, but here's what he did. ItsJZaid 45 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
--//Variables
local player = game:GetService("Players").LocalPlayer;
local userInputService = game:GetService("UserInputService");

local timeLimit, canJump = 3, true;
local finished = false;

--//Events
userInputService.JumpRequest:Connect(function()
    if player.Character then
        local humanoid = player.Character:FindFirstChild("Humanoid");
        if humanoid then
            humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, canJump); --Cancel jump if they can't jump, or let them jump
        end;
    end;
end);

local deb = true;
workspace:FindFirstChild("ClimbStart").Touched:Connect(function(hit)
    if deb then
        deb = not deb;
        local character = player.Character;
        if character then
            if hit.Parent == character then
                delay(timeLimit, function()
                    if not finished then
                        canJump = false;
                        local h = character:FindFirstChild("Humanoid");
                        if h then
                            h.Sit = true;
                        end;
                        wait(timeLimit);
                        canJump = true;
                        if h then
                            h.Sit = false;
                        end;
                    end;
                end);
            end;
        end;
        deb = not deb;
    end;
end);

workspace:FindFirstChild("ClimbDone").Touched:Connect(function(hit) --Green block
    local character = player.Character;
    if character then
        if hit.Parent:IsA("Model") and hit.Parent == character then
            finished = true;
        end;
    end;
end);
0
This is unnecessarily complicated Ziffixture 6913 — 4y

Answer this question