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

I can't re-enable the script any suggestions?

So I have a part that enables a script and a GUI which disables the script. So if I touch the part(This enables the script) and after I disable the script(with the GUI) after I can't enable the script again with touching the part! The output doesn't give any error and I use server script for the part(that enables the script) and local script for the disable(GUI).

The disabler script(local script):

local LocalPlayer=game:GetService("Players").LocalPlayer
local Button = script.Parent
---------------------------------------------------------
Button.MouseButton1Click:Connect(function()
	print("Disabled!")
	LocalPlayer.PlayerGui:FindFirstChild("FurniturePicker").FurnitureList.PlacementHandler.Disabled = true
end)

The enabler script(server script):

local object = script.Parent

function onTouch(part) 
	local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
	if humanoid == nil and humanoid.Health <= 0 then return end
	local player = game.Players:GetPlayerFromCharacter(part.Parent)
	if player == nil then return end
	print("Enabled!")
	player.PlayerGui:FindFirstChild("FurniturePicker").FurnitureList.PlacementHandler.Disabled = false
end 

script.Parent.Touched:connect(onTouch)

1 comment

0

You cannot access PlayerGui using a server-sided script. Use a LocalScript instead.

1 answer

You cannot access PlayerGui using a server-sided script. Use a LocalScript instead.

2 comments

1

While technically, you CAN access the PlayerGui from the server. You can't access guis in there unless they were cloned from the server; which unfortunately isn't how StarterGui clones them.

0

the script works for the first time but if i want to re-enable it nothing happens (for the secodn time)

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