im trying to make a GUI show up when a part is touched by the player, however, when i test the script, it tells me “Jumpscare is not a valid member of StarterGui “StarterGui””
the code is below
function Touched(Player)
local Character = Player.Parent
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
if Humanoid and Humanoid.Health > 0 then
local Player = players:GetPlayerFromCharacter(Character)
local PlayerGui = Player.PlayerGui
local Jumpscare = game.StarterGui.Jumpscare
wait(.001)
Jumpscare:Clone()
Jumpscare.Parent = Player.PlayerGui
n:Clone().Parent = game.Workspace
wait(0.1)
v:Clone().Parent = game.Workspace
wait(0.1)
v:Play()
wait(0.1)
n:Play()
wait(1)
wait(0.1)
wait(0.1)
wait(.01)
while true do
Jumpscare.Enabled = false
wait(.01)
Jumpscare.Enabled = true
end
end
end
could someone possibly tell me what is wrong. i apologize for how messy it looks, i am going through and trying to update the code to an older game i created a while back.
Server scripts can control everything even overriding locking calls to it.
Got to jump around a bit for this one.
local part = workspace:WaitForChild("Part")
local players = game:GetService("Players")
local function Touched(hit)
local Character = hit.Parent
local Humanoid = Character and Character:FindFirstChildWhichIsA("Humanoid")
if Humanoid and Humanoid.Health > 0 then
local Player = players:GetPlayerFromCharacter(Character)
if Player then
local PlayerGui = Player:WaitForChild("PlayerGui")
local Jumpscare = PlayerGui:FindFirstChild("Jumpscare")
if Jumpscare then
Jumpscare.Enabled = true
end
end
end
end
part.Touched:Connect(Touched)
As in this case … now that the server has turned on enabled the client can’t change it.
The server has override control on it now until it restores it to the way it was.
I read an insightful explanation regarding this a couple of years ago that sums up why it is generally recommended to have the client handle UI-related changes:
because personal things needs personal permissions, such as client stuff, for example, server cannot access the Mouse Position of the client, only the client can
because touch is watching for the Parts in ur character if it touches the part u put the function in, it means the server sees the part, and the character at the same time, but server cannot see ur screen
I understand what you are saying … This is clearly a jumpscare popup gui that will be over in a bit. Something that a script like I posted could do simply, start to end totally securly and hidden to hackers. Do it anyway you like … there are always a few ways to do anything. Here I just go with what they gave me to work with.
if ure tryna avoid hackers deleting the jumpscare from their playergui so the localscript wont be able to scare them when u fire an remote event, im pretty sure they can also inject their own local script to delete everything the server tries to add to their playergui, for example
local ScreenGui = blabla -- the screengui u plan to put the jumpscare
ScreenGui.ChildAdded:Connect(function(child)
child:Destroy()
end)
but anyway, perhaps the reason for ur post that server cant find the Jumpscare to clone is maybe wrong spelling?
i think u replied to the wrong message, i was just tryna tell him that using serverscript to put the jumpscare directly into the player’s playergui IS NOT going to help him avoid hackers from avoiding the jumpscare, cuz hackers can also put their own local script that automatically deletes anything the server tries to insert into their player gui