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

(FIXED) Script gives me error when I try and locate a BoolValue in a ScreenGUI, how to fix?

Asked by 4 years ago
Edited 4 years ago

(Friend solved it for me) I am making a script that detects when a player respawns, that toggles a BoolValue inside of a ScreenGUI, but for some reason it gives me an error when I try and locate it via script. Here is my code:

local Players = game:GetService("Players")

local function onCharacterAdded(character)
    local plr = game.Players:GetPlayerFromCharacter(character)
    plr.PlayerGui.HauntedSS.UsingScript.Value = false --here is where the error occurs
    print(plr.Name .. " has spawned")
end

local function onCharacterRemoving(character)
    local plr = game.Players:GetPlayerFromCharacter(character)
    plr.PlayerGui.HauntedSS.UsingScript.Value = false 
    print(plr.Name .. " is despawning")
end

local function onPlayerAdded(player)
    player.CharacterAdded:Connect(onCharacterAdded)
    player.CharacterRemoving:Connect(onCharacterRemoving)
end

Players.PlayerAdded:Connect(onPlayerAdded)
1
Is this in a regular Script or LocalScript? And where is this script located? AntiWorldliness 868 — 4y
0
It's a regular script in ServerScriptService, but it's fixed already, thanks though! HauntedDestroyer 106 — 4y

Answer this question