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 9 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.

01local f = true
02script.Parent.Touched:connect(function()
03    game.StarterGui:WaitForChild("TalkingGui")
04    if f == true
05        then
06        f = false
07    wait(10)
08    game.StarterGui.TalkingGui.TextLabel.Text = "Woah...W-What in the world was that?"
09    wait(3)
10    game.StarterGui.TalkingGui.TextLabel.Text = "Maybe I should get out of here..."
11    wait(3)
12    game.StarterGui.TalkingGui.TextLabel.Text = " "
13    print("Talking successful!")
14    wait(10)
15    f = true
16    end
17    end)

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 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:

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

Any questions? Be sure to comment!

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

Answer this question