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

When a player touches a part, can it make a GUI appear only to that player?

Asked by 6 years ago

I was curious to know if there was any way to make a GUI change only for one person who touches a certain brick? I would be using It as a way for them to tell what the temperature in-game is. For instance going outside into a desert area would make the temp go up. Thanks!

3 answers

Log in to vote
0
Answered by
Dad_Bot 34
6 years ago

Yes. There is no extra coding required for this either, ScreenGUIs are always client based so any code that is inserted will only effect that player's GUI.

Here is an example: If you are in a game and open a menu, the menu only opens for you, nobody else. Same concept with your idea, the temperature will only change for the local player.

Ad
Log in to vote
0
Answered by
65225 80
6 years ago

Yes, you can use the Touched function to access a gui in the player.

game.Workspace.NameOfPart.Touched:connect(function(plr)
    if plr.Parent:FindFirstChild("Humanoid") then
        plr.PlayerGui.NameOfGuiYouWantToChange
end)

Hope I helped! Please accept my answer if I answered your question!

Log in to vote
0
Answered by 6 years ago

This is an example of what you need.

Make a script inside the brick you want to be Touched. Then make a local script inside StarterGui.

Name your local and normal script something In this case ill name the local script "Loc" and the normal script "nor"

This is for the normal script inside the part.

local tochPart = script.Parent 
local nor = game:GetService("StarterGui").nor

nor.Enabled = false
tochPart.Touched:connect(function()
    wait(.1)
    nor.Enabled = true 
end)

Then for the local script. Make variables with a number value for the temperature. Then make a GUI for a temperature bar. After that use tweening for making the temperature bar raising. I suggest making a invisible wall that the player can walk through that has a Touched Event for change the GUI bar.

EX.

local desTemp = 100 -- temperature of desert
local snoTemp = 10 -- temperature of snow
local desWall = game.workspace.desWall -- desert enter wall
local snoWall = game.workspace.snoWall -- snow enter wall
local tempGui = script.Parent.TempFrame -- GUI bar for temperature


desWall.Touched:connect(function()
    tempGui:TweenSize(Udim2.new(desTemp,0 ,0,0), "In" ,"Quad", 1 )
end)

snowWall.Touched:connect(function()
    tempGui:TweenSize(Udim2.new(snoTemp,0 ,0,0), "In" ,"Quad", 1 )
end)

Answer this question