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

My script compiles but doesn't do anything, help?

Asked by 8 years ago

I've written 3 different scripts; 2 of which are working. I seperated them because of some issues I was having with the onTouched function and it repeating and whatnot. Anyways, that's not the point; My third script compiles, and prints the success message into the outbox, but isn't really doing it's job. Here it is.

local f = true
script.Parent.Touched:connect(function()
    game.StarterGui:WaitForChild("TalkingGui")
    if f == true
        then
        f = false
    wait(10)
    game.StarterGui.TalkingGui.TextLabel.Text = "Woah...W-What in the world was that?"
    wait(3)
    game.StarterGui.TalkingGui.TextLabel.Text = "Maybe I should get out of here..."
    wait(3)
    game.StarterGui.TalkingGui.TextLabel.Text = " "
    print("Talking successful!")
    wait(10)
    f = true
    end
    end)

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
8 years ago

Ahh, I see your issue. It is doing its job that you assigned it, which is changing a GUI's text located in StarterGui. For it to change the player's GUI, you have to go inside the PlayerGui. The following solution is assuming this game isn't FilteringEnabled:

local f = false -- just so it won't confuse me
script.Parent.Touched:connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) and f == false then -- Checks if it's a player. You can look 
on the wiki for a little more explanation
        local f = true
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        wait(10)
        plr.PlayerGui.TalkingGui.TextLabel.Text = "Woah...W-What in the world was that?"
        wait(3)
        plr.PlayerGui.TalkingGui.TextLabel.Text = "Maybe I should get out of here..."
        wait(3)
        plr.PlayerGui.TalkingGui.TextLabel.Text = ""
        print("Talking Successful!")
        wait(10)
        f = false
    end
end)

Any questions? Be sure to comment!

0
Thanks! This did fix the issue. I forgot about the player gui thing. clalexander 40 — 8y
Ad

Answer this question