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

My ring for service bell is not working?

Ok so this is in the output when I click it Workspace.Ring For Service.Script:4: attempt to index local 'player' (a nil value) this is the script

script.Parent.ClickDetector.MouseClick:connect(function(click)
	local chr = click.Parent
	local player = game.Players:GetPlayerFromCharacter(click.Parent)
	local gui = player.PlayerGui.Bank.Bank2
	gui.Visible = true
end)

On my function im trying to use click to describe as the person who clicked the bell I have a clickdetector a humanoid and a head in a model to say Ring For Service

OUTPUT:
Workspace.Ring For Service.Script:4: attempt to index local 'player' (a nil value)

1 answer

✓ Accepted answer

The parameter the MouseClick event gets is the player who clicked.

It's not a thing inside their character, so chr and player aren't being constructed reasonably.

script.Parent.ClickDetector.MouseClick:connect(function(player)
    local gui = player.PlayerGui.Bank.Bank2
    gui.Visible = true
end)

Note that you should be using FilteringEnabled to make games, and FilteringEnabled won't let a Script object reach into a player's PlayerGui.

2 comments

0

Actually Blue, eLunate corrected me on this not too long ago. As long as the ServerScript creates the Gui elements a ServerScript may modify those elements in the PlayerGui. However with things that a client clones, say from StarterGui, the server will hold no control over that in a FilteringEnabled environment.

0

Sure, but the server shouldn't be inserting any screegui into the player's playergui.

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