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

BoolValue is not a valid member of Player?

Asked by 2 years ago
Edited 2 years ago

Error : Image (Sorry i can't use imgur.)

Local Script :

local a = game.Players.LocalPlayer.EnableSpawner





while true do
    wait()
    if a.Value == true then
    local part = Instance.new("Part",workspace)
    part.Name = "SpawnedPart"
    part.Size = Vector3.new(3, 3, 3)
    part.Color = Color3.new(0.0627451, 0.752941, 1) 
    part.Transparency = 0.4
    part.Position = game.Workspace.Spawner.Part.Position
    part.Anchored = false
    end
end

Local Script2:

local plr = game.Players.LocalPlayer



script.Parent.Button.MouseButton1Click:Connect(function()
    script.Parent.click_sound:Play()
    if script.Parent.Button.Text == "Start" then
        plr.EnableSpawner = true
        script.Parent.Button.Text = "Stop"
    elseif script.Parent.Button.Text == "Stop" then
        plr.EnableSpawner = false
        script.Parent.Button.Text = "Start"
    end
end)

leaderstats script:

local ds = game:GetService("DataStoreService"):GetDataStore("PlayerData")

game.Players.PlayerAdded:Connect(function(plr)
    local ls = Instance.new("Folder",plr)
    ls.Name = "leaderstats"

    local score = Instance.new("IntValue",ls)
    score.Name = "score"
    score.Value = 0

    local enabled = Instance.new("BoolValue",plr)
    enabled.Name = "EnableSpawner"
    enabled.Value = false

    local d = ds:GetAsync(plr.UserId)
    if d then
        score.Value = d[1] or 0
    end 
end)

game.Players.PlayerRemoving:Connect(function(plr)
    local plrdata = {plr.leaderstats.score.Value,}
    ds:SetAsync(plr.UserId,plrdata)
end)

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

You should probably wait for the BoolValue.The issue is the second localscript.

Option 1: Use a WaitForChild()

local plr = game.Players.LocalPlayer
local EnableSpawner = plr:WaitForChild("EnableSpawner")

script.Parent.Button.MouseButton1Click:Connect(function()
    script.Parent.click_sound:Play()
    if script.Parent.Button.Text == "Start" then
        EnableSpawner = true
        script.Parent.Button.Text = "Stop"
    elseif script.Parent.Button.Text == "Stop" then
        EnableSpawner = false
        script.Parent.Button.Text = "Start"
    end
end)

Option 2: Use a repeat

local plr = game.Players.LocalPlayer

repeat wait() until plr.EnabledSpawner

script.Parent.Button.MouseButton1Click:Connect(function()
    script.Parent.click_sound:Play()
    if script.Parent.Button.Text == "Start" then
        plr.EnableSpawner = true
        script.Parent.Button.Text = "Stop"
    elseif script.Parent.Button.Text == "Stop" then
        plr.EnableSpawner = false
        script.Parent.Button.Text = "Start"
    end
end)
0
thx im gonna try this! totosimamora608 61 — 2y
Ad

Answer this question