I'm fairly new to scripting and I'm making a Obby, I'm trying to figure out a way to have a "Easy Mode" which would be not taking damage to KillBricks if you have a specific gamepass I'm also trying to make a GUI where you can toggle a button to turn Easy Mode on and off (only gamepass owners can use this feature)
script.Parent.Touched:Connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid.Health = 0 end end)
This is my killbrick script which works fine ^^^
local Id = 45525748 game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) if purchased and Id == ido then game.Workspace.Killpart.Script.Disabled = true end end) game.Players.PlayerAdded:Connect(function(plr) if game:GetService("MarketplaceService")UserOwnsGamePassAsync(plr.UserId.Id) then game.Workspace.Killpart.Script.Disabled = true end end)
This was my previous script trying to make it It didn't work AT ALL either maybe someone could help me fix this script or just give me idea's
local GamePassService = game:GetService('GamePassService') local GamepassID = 45525748 if GamePassService:PlayerHasPass(game.Players.LocalPlayer, GamepassID) then game.Workspace.Killpart.Script.Disabled = true end
This code needs to be in a LocalScript parented to StarterPlayerScripts.
This is untested. If it does not work, please tell me. Otherwise please accept the solution.
Put a BoolValue inside of all KillBricks. Then, you make a LocalScript inside StarterPlayer > StarterCharacterScripts. Inside the LocalScript it should be like this:
local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:wait() or script.Parent local hum = char:WaitForChild("Humanoid") hum.Touched:Connect(function(hit, limb) if hit:FindFirstChild("CanKillPlayer") and not char:FindFirstChild("IsImmortal") then if hum.Health > 0 and limb.Name ~= "Part" then hum.Health = 0 end end end)
Then, in a script inside ServerScriptService, put this code:
local Id = 45525748 game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) if purchased and Id == ido then local BoolValue = Instance.new("BoolValue", plr.Character or plr.CharacterAdded:wait()) BoolValue.Name = "IsImmortal" end end) game.Players.PlayerAdded:Connect(function(plr) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId.Id) then local BoolValue = Instance.new("BoolValue", plr.Character or plr.CharacterAdded:wait()) BoolValue.Name = "IsImmortal" end end)
That's all of it! I hope it works and lemme know if there are mistakes or errors. Have a good day! ^^