Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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!

1 comment

0

Thanks! This did fix the issue. I forgot about the player gui thing.

This discussion is preserved as it was. New answers, comments, and votes are closed.