Hello! I'm making an obby and I have a script which disables the script of every kill part if you have a certain gamepass, sort of like an easy mode. However, they only work on a few of them, and they're all parts I made first, before all the others. Additionally, I discovered that the scripts that do get disabled, are disabled for everyone in the server, which I don't want. An error pops up "Script is not a valid member of Part", I don't understand why this happens.
Easy Mode Script:
local id = #######
local killPartFolder = game.Workspace.killParts
for i, part in pairs (killPartFolder:GetChildren()) do
end
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
if purchased and id == ido then
for i, part in pairs (killPartFolder:GetChildren()) do
part.Script.Disabled = true
end
end
end)
game.Players.PlayerAdded:Connect(function(plr)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id)then
for i, part in pairs (killPartFolder:GetChildren()) do
part.Script.Disabled = true
end
end
end)
I'll also add the script for the kill parts. It doesn't actually "kill" the player, it teleports them back to their last checkpoint.
Kill Script:
local debounce = false
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local tp = workspace.Stages[player.leaderstats.Stage.Value]
local char = hit.Parent
if debounce == false then
if char:FindFirstChild("Humanoid") then
char:moveTo(tp.Position + Vector3.new(0,10,0))
wait(1)
end
debounce = false
end
end)

1 comment
Thank you! This works!