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

Can someone please help me make a local script that increases max HP?

Asked by 5 years ago

Can someone please help me make a local script that increases a player's max Hp after they buy a game pass?

I have tried for a few hours to make this local script but it won't work. this is what I have so far... local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players")

local gamePassID = 6609505 -- Change this to your game pass ID

local function onPlayerAdded(player)

01local hasPass = false
02 
03-- Check if the player already owns the game pass
04local success, message = pcall(function()
05    hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
06end)
07 
08-- If there's an error, issue a warning and exit the function
09if not success then
10    warn("Error while checking if player has pass: " .. tostring(message))
11    return
12end
13 
14if hasPass == true then
15    print(player.Name .. " owns the game pass with ID " .. gamePassID)
16    player.CharacterAdded:Connect(function(character)
17       local humanoid = character:FindFirstChild("Humanoid")
18       humanoid.MaxHealth = 500
19   end)
20end

end

-- Connect 'PlayerAdded' events to the 'onPlayerAdded()' function Players.PlayerAdded:Connect(onPlayerAdded)

Can someone please help me???

0
I can help you. Add me on discord ToxicScript TV #6171 RBLXNogin 187 — 5y
0
The reason for your error is because you need something called a "Remote Event". Running something client side only changes it for the user's device RBLXNogin 187 — 5y
0
Or change local script to server script. You don't need it to be in local. OnaKat 444 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Your issue should be due to the Filter Enabled feature on workspace. It is a key way to prevent your game from being exploiting, but disables the ability to change non local values. I would create a RemoteEvent in ReplicatedStorage and make a function inside a Server-Side script that does the function for increasing max health.

01--//SERVER SIDE// (Script)
02game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, humanoid, val)
03     humanoid.MaxHealth = val
04end)
05 
06 
07 
08 
09 
10 
11 
12--//CLIENT SIDE// (Local Script)
13local hasPass = false
14 
15-- Check if the player already owns the game pass
View all 32 lines...

Something like this should work.

0
Easier just change the local script into server script. OnaKat 444 — 5y
Ad

Answer this question