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

Why Does This Client-Sided Script for Hovering Over a Button Not Work with FilteringEnabled?

I have a SurfaceGui that is deposited into the player's PlayerGui and adorned to a part in the Workspace.** When I test it in the Studio, the image changes just fine, but in a server, nothing happens! Since the gui is client-sided, shouldn't this work?** I'm pretty new to FilteringEnabled, so there may be much that I need to learn.

This is my script, which is in the SurfaceGui of the PlayerGui.

debounce = false

script.Parent.MouseLeave:connect(function()
	if debounce == false then
		debounce = true
		script.Parent.Image = "http://www.roblox.com/asset/?id=615227711"
	end
	debounce = false
end)

script.Parent.MouseEnter:connect(function()
	if debounce == false then
		debounce = true
		script.Parent.Image = "http://www.roblox.com/asset/?id=615242781"
	end
	debounce = false
end)

At the start of the game, this SurfaceGui is deposited into the Player's PlayerGui and then adorned to a part via this RemoteEvent in the Workspace.

script.SetAdornee.OnServerEvent:connect(function(player)
	local p = game.Players:WaitForChild(player.Name, 10)
	local findGui = p:WaitForChild("PlayerGui", 10)
	local giveGui = game.ServerStorage.Gui.TitleGui:Clone()
	giveGui.Parent = findGui
	giveGui.Adornee = game.Workspace.StartMenuArea.Classroom.Board
end)

This LocalScript in the StarterPack fires the RemoteEvent at the start of the game.

player = game.Players.LocalPlayer
game.Workspace.RemoteEvents.SetAdornee:FireServer(player)

Any and all help is most certainly appreciated!

1 answer

ServerScripts can't see a players PlayerGui. GUI's should be completely handled from the client. Set the adornee to the desired part from the client, no need for events to the server.

(If I'm correct you should get an error in your server log while playing in online mode. (Hit f9 to open the console!))

2 comments

0

I created a script that sets the Adornee to the part from the client, but when I hover the mouse over the button, nothing happens still. I've also checked the developer console and nothing showed up. Why is this?

0

Try adding some print("positionOfPrint") 's inside your script to find out where it does and where it doesn't come.

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