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
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.
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.
--]]
-- 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.