I’m trying to make this script appear for the one person who touches it but when its touched every player in the server gets cycled through and given it.
Players = game:GetService("Players")
local Hot = script.Parent.Parent.Parent.Parent.LabEntrance.Plap
local sound = "rbxassetid://8871318721"
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
for i, player in pairs(game.Players:GetPlayers()) do
task.wait(.25)
player.PlayerGui.SecretQuotes.Secret1.Enabled = true
player.PlayerGui.SecretQuotes.Secret1.Last.Frame.Text.Script.Disabled = false
task.wait(3.75)
player.PlayerGui.SecretQuotes.Secret1.Enabled = false
player.PlayerGui.SecretQuotes.Secret1.Last.Frame.Text.Script.Disabled = true
player.Character.HumanoidRootPart.Position = Hot.Position
end
end
end)
just having trouble making it appear for the one person only its a serverscript.
Use a LocalScript. Code inside runs exclusively on the client and due to replication boundary’s any guis you choose to display through them should only appear for them. Please be aware they only run in the following locations however.
Players = game:GetService("Players")
local Hot = script.Parent.Parent.Parent.Parent.LabEntrance.Plap
local sound = "rbxassetid://8871318721"
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
for i, player in pairs(game.Players:GetPlayers()) do
if player.Name == hit.Parent.Parent.Name then
task.wait(.25)
player.PlayerGui.SecretQuotes.Secret1.Enabled = true
player.PlayerGui.SecretQuotes.Secret1.Last.Frame.Text.Script.Disabled = false
task.wait(3.75)
player.PlayerGui.SecretQuotes.Secret1.Enabled = false
player.PlayerGui.SecretQuotes.Secret1.Last.Frame.Text.Script.Disabled = true
player.Character.HumanoidRootPart.Position = Hot.Position
end
end
end
end)
For you to achieve this, you would use Server script. To get player’s GUI, you would GetPlayerFromCharacter() function
and then reference GetPlayerFromCharacter() as a player. Then, you would just Get the player GUI like this player.PlayerGui and then so on. You’re done
Players = game:GetService("Players")
local Hot = script.Parent.Parent.Parent.Parent.LabEntrance.Plap
local sound = "rbxassetid://8871318721"
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player= GetPlayerFromCharacter(hit.Parent.Parent)
if player then
task.wait(.25)
player.PlayerGui.SecretQuotes.Secret1.Enabled = true
player.PlayerGui.SecretQuotes.Secret1.Last.Frame.Text.Script.Disabled = false
task.wait(3.75)
player.PlayerGui.SecretQuotes.Secret1.Enabled = false
player.PlayerGui.SecretQuotes.Secret1.Last.Frame.Text.Script.Disabled = true
player.Character.HumanoidRootPart.Position = Hot.Position
end
end
local function GetPlayerFromObject(obj)
for k,v in next, game:GetService("Players"):GetPlayers() do
if not v.Character then
continue
end
if obj:IsDescendantOf(v.Character) then
return v
end
end
end
local Hot = script.Parent.Parent.Parent.Parent.LabEntrance.Plap
local sound = "rbxassetid://8871318721"
script.Parent.Touched:Connect(function(hit)
local player = GetPlayerFromObjects(hit) or error("not a player!")
player.PlayerGui.SecretQuotes.Secret1.Enabled = true
player.PlayerGui.SecretQuotes.Secret1.Last.Frame.Text.Script.Disabled = false
task.wait(3.75)
player.PlayerGui.SecretQuotes.Secret1.Enabled = false
player.PlayerGui.SecretQuotes.Secret1.Last.Frame.Text.Script.Disabled = true
player.Character.HumanoidRootPart.Position = Hot.Position
end)