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

How to use GUI's with filtering enabled?

Hello, I want to make a script (server script not local because then no one can see the hat) but the only problem is this script won't work in test but it works in play mode. I want that this work when you click on the gui you get this hat that everyone can see on server side not client side.

Ps. this is a server script in startergui but i think server scripts don't work in startergui.

function die()
local player = script.Parent.Parent.Parent.Parent
if player.Character:FindFirstChild(Hat")then
	else
	local arm = player.Character.Head
	local rift = game.ServerStorage.Hat:Clone()
	rift.Parent = player.Character
	rift.Head.Anchored = false
	local w = Instance.new("Weld")
	w.Name = "Weld"
	w.Parent = player.Character.Torso
	w.Part0 = rift.Head
	w.Part1 = arm
end
end
script.Parent.MouseButton1Down:connect(die)

1 comment

0

Use RemoteEvent

1 answer

✓ Accepted answer

You need to use a remote event, and no, scripts do not work in GUIs with filtering enabled

an example for the local script would be;

function die()
local player = script.Parent.Parent.Parent.Parent
if player.Character:FindFirstChild(Hat")then
    else
    game.Workspace.RemoteEvent:FireServer()
end
end
script.Parent.MouseButton1Down:connect(die)

Server script;

game.Workspace.RemoteEvent.OnServerEvent:connect(function(player)
    local arm = player.Character.Head
    local rift = game.ServerStorage.Hat:Clone()
    rift.Parent = player.Character
    rift.Head.Anchored = false
    local w = Instance.new("Weld")
    w.Name = "Weld"
    w.Parent = player.Character.Torso
    w.Part0 = rift.Head
    w.Part1 = arm
end)

this should work, if it doesn't just comment your questions, accept the answer if it did, it gives us both rep!

5 comments

0

local player = game.Players.LocalPlayer *

0

and "Hat"*

0

Thank you it worked but can you do this also for a gear?

0

Provided you give the gear on the server: yes, the same principles apply.

0

Nathan I just used his script, but added a remote event function

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