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

(edit) How to make players go in order through a story?

Asked by 6 years ago
Edited 6 years ago

I have been stuck on getting players to go in order on a story i have in my game. currently i have a brick that players step on that open up a GUI with part of the story line in it. all i have been doing is duplicating that object and its counterpart GUI. what i want to do is the following:

-player steps on story brick GUI #1 and the message pops up as it should. -this then unlocks story brick GUI #2 -if player steps on story brick GUI #2 before stepping on story brick GUI #1, the they get an alternate message such as "huh? who are you?" instead of the intended story

If current scripts are needed to help with this problem or you need more clarification to help please let me know!! i have been stuck on this problem for ages and dont know a way around it. Thanks for any help given!!

****EDIT BELOW

here is what i have in the brick:

local Part = script.Parent

Part.Touched:connect(function(HIT)
    local H = HIT.Parent:FindFirstChild("Humanoid")
    if H then
        local Player = game.Players:GetPlayerFromCharacter(HIT.Parent)
            Player.PlayerGui.ScreenGui2.Frame.Visible = true
    end
end)

i tried copy and pasting in the previous answer given, which didnt work and i tried to switch some things around from there but i dont currently know how to fix it still. Each GUI trigger brick is the exact same besides the GUI it opens. Thanks for the feedback so far!

0
That's the thing. The scripts in each block cannot be the same. I have edited below and hopefully it will work. zyrun 168 — 6y
0
Another thing that might be messing with this is Filtering Enabled zyrun 168 — 6y

1 answer

Log in to vote
0
Answered by
zyrun 168
6 years ago
Edited 6 years ago

There are many easy ways to do this, especially if you handle all the GUI events inside of the player in one LocalScript. Assuming that isn't the case, then this would be the solution:

Please note that is one of if not the most inefficient ways to do this, but it will work either way. This is inside of the brick that makes GUI2 pop up

script.Parent.Touched:Connect(function(Hit)--When the brick (script.Parent) is touched
    local Plr = game.Players:GetPlayerFromCharacter(Hit.Parent)--The Player that touched
    if Plr ~= nil then--Making sure it was a player who touched the brick, not some random part
        if not Plr:FindFirstChild("TalkedToFirst", true) then--If the GUI 1 NPC was NOT talked to first
            --You'll need to use what you're already using to make the "Huh, Who are you?" Pop up here
        elseif Plr:FindFirstChild("TalkedToFirst", true) then   --If the GUI 1 NPC was talked to first
            --You'll need to use what you're already using to make GUI2 Pop up here
        end
    end
end)

This lower section should be in the brick that makes GUI 1 pop up.

 script.Parent.Touched:Connect(function(Hit)
    local Plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
    if Plr ~= nil  then
        Instance.new("BoolValue", Plr).Name = "TalkedToFirst"--Puts this value inside of the player so that when the time comes, the game will know that this NPC has been talked to first
        --You'll need to use what you're already using the make GUI1 Pop up here
    end
end)

Hope this helped! - Zyrun

Ad

Answer this question