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

Hover problems, not copying to players gui?

I'm making a game that has a mechanic where when you hover over something a gui pops up.

serverStorage = game:GetService("ServerStorage")
tester1 = workspace.tester1
local player = game.Players.LocalPlayer

local clickDetector = Instance.new("ClickDetector", tester1)

script.Parent.ClickDetector.MouseHoverEnter:connect(function(Player)
	
		local guit = serverStorage.hoverf:Clone()		
		guit.Parent = player.PlayerGui
end)

Problem is that I get this error: 07:38:41.243 - Workspace.tester1.Script:10: attempt to index upvalue 'player' (a nil value)

1 comment

0

Try un-capitalizing Player on line 7

1 answer

From your script I can tell it is a Script and not a LocalScript. Scripts can't use game.Players.LocalPlayer. You'll need to define the player differently.

EDIT:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local tester1 = workspace:WaitForChilD("tester1")
local player = game.Players.LocalPlayer

local clickDetector = Instance.new("ClickDetector", tester1)

script.Parent.ClickDetector.MouseHoverEnter:connect(function(Player)

        local guit = ReplicatedStorage.hoverf:Clone()       
        guit.Parent = player.PlayerGui
end)

Put that script in ReplicatedFirst

3 comments

0

And how do you propose I do that?

0

You should actually make this a LocalScript, and put the stuff that's in ServerStorage in ReplicatedStorage and change serverStorage to replicatedStorage.

0

nothing happened

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