Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't this work in online mode?

This is my script.

 local Gui = script.Parent.ShopGui:clone()

function onTouched(hit)
	local human = hit.Parent:findFirstChild("Humanoid")
	local life = human.Parent.Name
	if (human ~= nil ) then
local Gui = script.Parent.ShopGui:clone()
Gui.Parent = game.Players.LocalPlayer.PlayerGui
	end
end
script.Parent.Touched:connect(onTouched)

In test mode, it works fine. But in online mode, the gui doesn't appear.

3 comments

0

Is it in a local script?

0

No, it is not in a local script.

0

You can't get LocalPlayer from players in a local script outside of studio

1 answer

✓ Accepted answer

On line 8 you are using "game.Players.LocalPlayer" If this script is not a local script then that can not be used. You could just find the player

 local Gui = script.Parent.ShopGui:clone()

function onTouched(hit)
    local human = hit.Parent:findFirstChild("Humanoid")
    local life = human.Parent.Name
    if (human ~= nil ) then
local Gui = script.Parent.ShopGui:clone()
Gui.Parent = game.Players:FindFirstChild(Life):WaitForChild("PlayerGui")
    end
end
script.Parent.Touched:connect(onTouched)

This discussion is preserved as it was. New answers, comments, and votes are closed.