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

How do I make it so when a part is touched it will change the Gui text?

Asked by
Cikeruw 14
2 years ago
Edited 2 years ago

Here is my script that i have

--scripts parent is a part that I want to trigger

script.Parent.Touched:Connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then game.ReplicatedStorage.RemoteEvent:FireClient(game.Players:GetPlayers(hit.Parent)) end end)

-- Script that I want to change the text

local RemoteEvent = game.ReplicatedStorage.RemoteEvent RemoteEvent.OnClientEvent:Connect(function() script.Parent.Text = "Found" end)

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

serverside script:

script.Parent.Touched:Connect(function(hit)
    local hum = hit.Parent:FindFirstChild("Humanoid")
    local Players = game:GetService("Players")
    if hum then
        game.ReplicatedStorage.RemoteEvent:FireAllClients(Players:GetPlayers(hit.Parent))
    end
end)

local script:

local RemoteEvent = game.ReplicatedStorage.RemoteEvent
RemoteEvent.OnClientEvent:Connect(function()
    script.Parent.Text = "Found"
end)

u were firing the client instead of AllClients. also put ur code ina code block next time

Ad

Answer this question