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

How would I make a script make a GUI visible on touch of a part?

It sounds pretty simple but for some reason, I can't get it working. Could someone explain to me the steps on how I would go about doing this? (This doesn't mean make a script for me, just explain how I would make it.

1 answer

✓ Accepted answer

Ok, before I explain more into this, you will need to know about the Touched event, about RemoteEvents, and most importantly, RemoteEvent.OnClientEvent.

So, let's create a function that we can use when calling the event.

function Touched(hit)

end

we need to get the humanoid from hit now so use hit.Parent:FindFirstChild("Humanoid"), and then use Players:GetPlayerFromCharacter(hit.Parent) to get the player

and we need to check if both the humanoid, and the player is here

function Touched(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player then
			--Empty
		end
	end
end

and now we need to Fire a remote event from the server, to open the script

function Touched(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player then
			RemoteEvent:FireClient(player, player)
		end
	end
end

And lastly, we need to call this function when the part is touched

script.Parent.Touched:Connect(Touched)

And now for the Client

function OnClientEvent(player)
	GuiObject.Visible = true
end

RemoteEvent.OnClientEvent:Connect(OnClientEvent)

1 comment

0

Thanks!

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