Once the player joins the game they have the X2 speed ability but once they die they lose it? I can't find a fix to this!? Any ideas why
Script in serverscriptservice
local MPS = game:GetService("MarketplaceService") local players = game:GetService("Players") local SpeedX2_ID = 8291824 MPS.PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) if purchased and SpeedX2_ID == ido then plr.Character.Humanoid.WalkSpeed.Value = plr.Character.Humanoid.WalkSpeed.Value * 2 end end) game.Players.PlayerAdded:Connect(function(plr) if MPS:UserOwnsGamePassAsync(plr.UserId,SpeedX2_ID) then game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed = game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed * 2 end end)
as racoon said but made it easier
the plr value will update each time someone joins so that way is not reliable instead do this make a local script in the players backpack or startercharacter, really doesnt matter in the local script you do this
--also when finishing the promt purchase, fire that to the server, let the server handle that sort of stuff MPS.PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) if purchased and SpeedX2_ID == ido then plr.Character.Humanoid.WalkSpeed.Value = plr.Character.Humanoid.WalkSpeed.Value * 2 end end) local player = game:GetService("Players").LocalPlayer player.CharacterAdded:Connect(function() --you also need a remove event for this to work game:GetService("ReplicatedStorage"):WaitForChild("Remove event name here"):FireServer("Speed")--speed is just a variable you wanna fire to the server, can be literally anything as long as the server looks for that variable end)
make a server script in serverscriptservice and add this into that script
local MPS = game:GetService("MarketplaceService") local SpeedX2_ID = 8291824 game:GetService("ReplicatedStorage"):WaitForChild("remote event name here").OnServerEvent:Connect(function(player,word) if word == "Speed" and MPS:UserOwnsGamePassAsync(plr.UserId,SpeedX2_ID) then--this is where you use the variable from the local script local humanoid = plr.Character:WaitForChild("Humanoid") humanoid.Speed = humanoid.Speed * 2 end)
Speed resets whenever a player dies. You'd need to have a CharacterAdded function. Example:
function Respawned(player) local plr = game.Players:FindFirstChild(player.Name) if MPS:UserOwnsGamePassAsync(plr.UserId,SpeedX2_ID) then game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed = game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed * 2 end end
local MPS = game:GetService("MarketplaceService") local players = game:GetService("Players") local SpeedX2_ID = 8291824 MPS.PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) if purchased and SpeedX2_ID == ido then plr.Character.Humanoid.WalkSpeed.Value = plr.Character.Humanoid.WalkSpeed.Value * 2 end end) game.Players.PlayerAdded:Connect(function(plr) if MPS:UserOwnsGamePassAsync(plr.UserId,SpeedX2_ID) 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,SpeedX2_ID) then game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed = game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed * 2 end end end)
The only change I made is when the player dies, it checks again and gives them their speed