Recently i started having this issue with a script, it’s supposed to make a GUI show up while you’re in a part region
The problem is that it has started throwing the error “Part parameter must be BasePart” and i have no idea how to fix it.
Code:
local replicated = game:GetService("ReplicatedStorage")
local ScreenEvent = replicated.Data:WaitForChild("Screen")
local p = workspace.SleepStuff:FindFirstChild("SleepingRegion")
local gui = gamer.PlayerGui:WaitForChild("SleepWakeBtn")
local screenval = gamer.PlayerGui.ScreenBlackout:WaitForChild("CheckVal")
local votingstate = replicated.Vote.Started
local overlap = OverlapParams.new()
local found
local runservice = game:GetService("RunService")
runservice.Stepped:Connect(function()
local t_table = workspace:GetPartsInPart(p, overlap)
for _, part in pairs(t_table) do
if part:IsA("BasePart") then
found = false
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player and player == gamer then
found = true
else
found = false
end
if found == true and replicated.Data.GameState.Value ~= "Changing" and screenval.Value == false and votingstate.Value == false then
gui.Enabled = true
break
else
gui.Enabled = false
end
end
end
end)
Edit: It also happens always after the player dies.
My best guess is that it tries to execute the script when the BasePart hasn’t loaded in yet.