Speed Gamepass resets whenever the player dies even though I made sure to make it active again once they die?!
ServerScript
local MPS = game:GetService("MarketplaceService") MPS.PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) if purchased and 8946555 == ido then plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed * 2 end end) game.Players.PlayerAdded:Connect(function(plr) if MPS:UserOwnsGamePassAsync(plr.UserId,8946555) then game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed = game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed * 2 end plr.Character:FindFirstChild("Humanoid").Died:Connect(function() wait(6) if MPS:UserOwnsGamePassAsync(plr.UserId,8946555) then game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed = game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed * 2 end end) end) game.ReplicatedStorage.Speed.OnServerEvent:Connect(function(plr) plr.Character:WaitForChild("Humanoid").WalkSpeed = plr.Character:WaitForChild("Humanoid").WalkSpeed * 2 end)
PrompPurchase
local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local GamepassID = 8946601 -- Change this to your developer product ID -- Function to prompt purchase of the developer product script.Parent.MouseButton1Click:Connect(function() MarketplaceService:PromptGamePassPurchase(game.Players.LocalPlayer, GamepassID) end) MarketplaceService.PromptGamePassPurchaseFinished:connect(function(player, id, purchased) if id == GamepassID and purchased then game.ReplicatedStorage.VIP:FireServer() end end)
It's actually very simple :D
I once struggled with this too, i know it's a pain in the ass not getting things done.
We simply use a function called .CharacterAdded
Every-time the player loads in, this function will be called. Useful in calculating the players deaths
Here's a short example:
game.Players.LocalPlayer.CharacterAdded:Connect(function() print("The player just died, or loaded in") end)
I won't tell you the script, but it's got to do something with this. Why you may ask?
You learn by researching, and improvising.
This is how i learned LUA.
Enjoy your scripting career!
just add a CharacterAdded
to check when the player's character is added and change the walkspeed
new server script:
local MPS = game:GetService("MarketplaceService") MPS.PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) if purchased and 8946555 == ido then plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed * 2 end end) game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) if MPS:UserOwnsGamePassAsync(plr.UserId,8946555 ) then char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed * 2 end end) end) game.ReplicatedStorage.Speed.OnServerEvent:Connect(function(plr) plr.Character:WaitForChild("Humanoid").WalkSpeed = plr.Character:WaitForChild("Humanoid").WalkSpeed * 2 end)
I would suggest using a while loop to check whether the player has died then promptgamepasspurchase on line 14 And I'm on mobile so I can't test it
Script ~~~~~~~~~~~~~~~~~
~~~local MPS = game:GetService("MarketplaceService")
MPS.PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) if purchased and 8946555 == ido then plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed * 2 end end)
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) if MPS:UserOwnsGamePassAsync(plr.UserId,8946555 ) then char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed * 2 end end) end)
game.ReplicatedStorage.Speed.OnServerEvent:Connect(function(plr)
plr.Character:WaitForChild("Humanoid").WalkSpeed = plr.Character:WaitForChild("Humanoid").WalkSpeed * 2
end)~~~~~~~~~~~~~