So, I've made this game and I've been doing pretty well with all of the scripting, but there is this one thing that confuses me.
So once you enter your hotel room, it Turns night [There's no problem with that.], then it turn the heading [It's a GUI not a Hint.] to "Why did it turn night?" But that didn't work. Here's the script:
function onTouched() game.Lighting.TimeOfDay = "21:00:00" game.StarterGui.ScreenGui.TextButton.Text = "Why did it turn night?" end script.Parent.Touched:connect(onTouched)
Help...?
Changing the Gui in StarterGui will not do anything for the player. The Gui that the player sees is actually inside their PlayerGui (located in their player). You can access this by using the GetPlayerFromCharacter
method on the Players service. The argument for that method is the character of whom you are trying to find the player from.
function onTouched(hit) --Hit is the part that touched the part you have this script inside. local character = hit.Parent --Since hit is the part that touched your brick, it would be the character's limb. The part of the limb is the entire character. local player = game.Players:GetPlayerFromCharacter(character) --Using the GetPlayerFromCharacter method stated above, we can access the player and it's children through this script. if player ~= nil then --In case another brick that wasn't the player's limb touched it. game.Lighting.TimeOfDay = "21:00:00" player.PlayerGui.ScreenGui.TextButton.Text = "Why did it turn night?" --Notice how we access "PlayerGui" inside the player rather than the StarterGui in game. end end script.Parent.Touched:connect(onTouched)
Here is the ROBLOX Wiki page on PlayerGui.
Here is the ROBLOX Wiki page on GetPlayerFromCharacter, the method we used to access the player.
If I helped you out, be sure to accept my answer! :D