Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Hover problems, not copying to players gui?

Asked by
NRCme 0
8 years ago

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)

0
Try un-capitalizing Player on line 7 kelimeguy 60 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

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

0
And how do you propose I do that? NRCme 0 — 8y
0
You should actually make this a LocalScript, and put the stuff that's in ServerStorage in ReplicatedStorage and change serverStorage to replicatedStorage. 0xDEADC0DE 310 — 8y
0
nothing happened NRCme 0 — 8y
Ad

Answer this question