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

when player touch part it change text in gui?

when player touch part it change text in gui?

3 comments

0

What do you want exactly?

0

If I got it right, you want it so when a player touches a part, text changes in the gui? I can't really go into detail because not much information has been given. Can you give us more detail?

0

yep

1 answer

--[[
	This is a LocalScript. Insert it into StarterGui.
--]]

local gui = game.StarterGui["YourGuiName"]

local frame = gui["YourFrameName"]

local t = frame["YourTextName"]

game.ReplicatedStorage.TouchedFunction:FireServer()

game.ReplicatedStorage.TouchedFunction.OnClientEvent:Connect(function()
	t.Text = "hello lol" -- You can edit this however you like
end)

Server:

--[[
 	This is a server script. You should insert it into ServerScriptService
--]]

game.ReplicatedStorage.TouchedFunction.OnServerEvent:Connect(function(plr)
	workspace["YourPartName"].Touched:Connect(function(hit)
		if hit.Parent then
			if hit.Parent:FindFirstChildOfClass("Humanoid") then
				local plr2 = game.Players:FindFirstChild(hit.Parent.Name)
				
				if plr2.Name == plr.Name then
					game.ReplicatedStorage.TouchedFunction:FireClient(plr)
				end
			end
		end
	end)
end)

EDIT: I accidentally made an error on the Server, fixed it now!

EDIT2: Fixed the LocalScript. Replace YourGuiName, YourFrameName, and YourTextName with whatever the name of it is.

Good day!

3 comments

0

soo where i paste the local script i know to startergui but to gui i made or what?

0

its spawns text it don't change my text in gui

0

My mistake! ???? Updating to fix now!

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