I tested my game and instantly saw an error about Argument 1 missing or nil
Here's the script (The problem is Line 1)
local Playar = game.Players:GetPlayerFromCharacter() local Start = Playar.PlayerGUI --[[local RobuxGUI = game.ReplicatedStorage["R$GUI"]:Clone() RobuxGUI.Parent = Start]] script.Parent.Touched:connect(function(Hit) local Character = Hit.Parent if Start["R$GUI"] ~= nil or Start["HelpGUI"] ~= nil then print("") elseif Start["R$GUI"] == nil or Start["HelpGUI"] == nil then local RobuxGUI = game.ReplicatedStorage["R$GUI"]:Clone() RobuxGUI.Parent = Start end end)
If I'm using this GetPlayerFromCharacter function wrong, may I be given an example or something to help?
You need the character model in between the "()" in get player from character.
script.Parent.Touched:connect(function(Hit) local Character = Hit.Parent local Playar = game.Players:GetPlayerFromCharacter(Character) --You need the character in this argument local Start = Playar.PlayerGUI --[[local RobuxGUI = game.ReplicatedStorage["R$GUI"]:Clone() RobuxGUI.Parent = Start]] if Start["R$GUI"] ~= nil or Start["HelpGUI"] ~= nil then print("") elseif Start["R$GUI"] == nil or Start["HelpGUI"] == nil then local RobuxGUI = game.ReplicatedStorage["R$GUI"]:Clone() RobuxGUI.Parent = Start end end)
Not really that complicated. Hope it helps!
I would like to add that
if parent.child ~= nil then
won't work.
Before you check if it doesn't equal nil, you're already assuming there actually is an object to check! While checking if it exists, you're already assuming that "it" does indeed exist. If "it" doesn't exist, you just indexed a nil value, and the script will error.
You need to use the FindFirstChild()
method. It will look for the child, and return that child if it exists. If not, it will return nil. Since it works like a function, instead of throwing an error it will simply become nil
.
if parent:FindFirstChild("child") ~= nil then