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

when player touch part it change text in gui?

Asked by 2 years ago

when player touch part it change text in gui?

0
What do you want exactly? oldmantv12345 9 — 2y
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? robert19735 17 — 2y
0
yep mybuldingbames 9 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago
--[[
    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!

0
soo where i paste the local script i know to startergui but to gui i made or what? mybuldingbames 9 — 2y
0
its spawns text it don't change my text in gui mybuldingbames 9 — 2y
0
My mistake! ???? Updating to fix now! LikeableEmmec 470 — 2y
Ad

Answer this question