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

Why can my handcuff script not locate the scripts placed in StarterGui?

Asked by 5 years ago

This script is used as a handcuff script. It is meant to disable the players ability to chat and reset, but the script is a server script, so I am having to use external scripts to handle this. I have placed two separate scripts in StarterGui, one disabling chat and reset while the other enables it. As you can see towards the bottom of this script there are a few lines in the code that enable and disable these scripts. But it isn't working.

I am given the error "ChatDisable is not a valid member of PlayerGui".

sub=nil
script.Parent.Equipped:Connect(function()
    script.Parent.Clicker.OnServerEvent:Connect(function(player,target)
        if target~=nil then 
            pcall(function() sub.Parent.Torso.Anchored=false end)
            sub=target
            player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
            if sub.Parent:FindFirstChild("Torso")~=nil and player then
                sub.Parent.Torso.Anchored=true
                coroutine.wrap(function()
                    while sub.Parent.Torso.Anchored do wait()
                    sub.Parent.Torso.CFrame=player.Character.Torso.CFrame*CFrame.new(0,0,-7)
                    player.PlayerGui.ChatDisable.Disabled = true
                    player.PlayerGui.ChatEnabled.Disabled = false
                    end
                end)()
                            else
                    player.PlayerGui.ChatDisable.Disabled = false
                    player.PlayerGui.ChatEnabled.Disabled = true
            end
        end
    end)
end)
1
The server cannot access a players gui, so you would need to make a RemoteFunction which will Invoke the Client telling it to disabled the scripts. Then you'd make a LocalScript that will watch for that invoke. https://www.robloxdev.com/api-reference/function/RemoteFunction/InvokeClient YouSNICKER 131 — 5y

Answer this question