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

how do I make my sell home gui button script work on filtering enabled?

This is a NORMAL script inside the gui button

function onButtonClicked()
local x = game.Workspace:FindFirstChild("Home"..script.Parent.Parent.Parent.Parent.Name)
if not (x) then
return
else
x.Home:Remove()
x.Name = "Home"
wait(.5)
s = game.Lighting["Home"..script.Parent.Parent.Parent.Parent.Name]
s.Parent = x
s.Name = "Home"
end
end
script.Parent.MouseButton1Click:connect(onButtonClicked)

1 answer

When scripting with Guis, you should use a localscript. For FilteringEnabled Client-to-Server communication (basically, a player's computer sending a message to the server), you should use RemoteEvents. I'll show you an example. Lets say you have a RemoteEvent in game.ReplicatedStorage. This example has a button that, when clicked, adds a part to the workspace.

-- LocalScript
-- The Parent is a TextButton, parented a ScreenGui that is parented to the PlayerGui.

local Button = script.Parent
local Remote = game.ReplicatedStorage:WaitForChild('RemoteEvent')

Button.MouseButton1Click:Connect(function()
  Remote:FireServer()
end)
-- Script
-- The Parent i game.ServerScriptService

local Remote = game.ReplicatedStorage:WaitForChild('RemoteEvent')

Remote.OnServerEvent:Connect(function(Player)
  local Part = Instance.new('Part', workspace)
  print(Player.Name .. ' added a part to the workspace!')
end)

When doing something that ALL players should see, use a server script (aka a Script). When doing something that only ONE player should see, use a local script. LocalScripts should be in a Player's PlayerScripts, PlayerGui, a Tool, or a Player's Character. Hope this helped..

2 comments

0

I placed the script into a local script and it didn't work

0

dude your supposed to edit the script above it doesnt even have to do your script right now...

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