Another problem with gui

so basically i want my part to touch a “player” to enable a frame not a player. How do i make it do that??
here is the script ( its pretty simple btw):
local frame = script.Parent

game.Workspace.Part.Touched:Connect(function(hit)

frame.Visible = true

end)

and heres a pic:

1 Like

I’m not sure if you can use touched event on local scripts. They won’t work.

2 Likes

It’s probably not the best way to detect touch, I’d do it server-side but if you put your script into a local script then it should work.

local frame = script.parent
game.Workspace.Part.Touched:Connect(function(hit)
	frame.Visible = true
end)
3 Likes

They’re not using a local script tho.

2 Likes

You can’t use a normal script inside game.Players.LocalPlayer so you would have to change that script into a LocalScript

2 Likes

Server scripts dont run in starter gui

2 Likes

what do you mean server side? btw im new im still watching alvin blox vids

1 Like

Server sided script means that it is a normal script that runs on the server. A LocalScript runs on the client that doesn’t affect the rest of the server.

2 Likes

Here are two scripts I made for you. Since you’re new, I added some explications.

SERVER SCRIPT (game.ServerScriptService)

-- Variables

local Part = game.Workspace.Path.To.Your.Part
local RemoteEvent = Instance.new("RemoteEvent", game.ReplicatedStorage)
RemoteEvent.Name = "DisplayFrame"

--[[

EXPLICATIONS OF: Variables

The Part variable is the part you want players to touch in order to view the Frame
The RemoteEvent  variable creates a RemoteEvent. RemotesEvents can be used to communicate between the server -> client and client -> server.

--]]

Part.Touched:Connect(function(Hit)
	
	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	
	if Player then
		
		RemoteEvent:FireClient(Player)
		
	end
	
end)

--[[

EXPLICATIONS OF: Touched event

The .Touched event fires whenever something touches your part.
The :GetPlayerFromCharacter returns the a player from a given Character.

--]]

Documentation for more information:

Instances
RemoteEvent

Events / Functions
.Touched
:GetPlayerFromCharacter
:FireClient

LOCAL SCRIPT (game.StarterGui)

-- Variables

local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("DisplayFrame")
local Frame = script.Parent -- Assuming you placed this LOCAL script into the Frame you want players to see

RemoteEvent.OnClientEvent:Connect(function()
	
	Frame.Visible = true
	
end)

-- The OnClientEvent event fires listening functions in LocalScript when either RemoteEvent:FireClient or RemoteEvent:FireAllClients is fired by the server from a Script.

Documentation for more information:

Events / Functions
.OnClientEvent

IMPORTANT NOTE
If you want the local script to enable a ScreenGui, you have to change line 8 (Frame.Visible = true) to Frame.Enabled = true.

Feel free to contact me if you still need help! ^^

3 Likes

thank u so much ! :smiley: (taking up space)

1 Like

I’m proud I helped you! Could you please mark my post as the solution so other people can view it if they need help? ^-^

1 Like

how do u do that??? (taking space)

1 Like