Hey there so i have this script and its supposed to change your walk speed on touch, if you own a gamepass. I dont know if ive done this wrong or anything, thanks.
local id = 7549271
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
if purchased and ido == id then
local db = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")~= nil then
if db == true then
db = false
plr.Character.Humanoid.Walkspeed = 40
end
end
end)
end
end)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId. id) then
local db = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")~= nil then
if db == true then
db = false
char.Humanoid.WalkSpeed = 40
end
end
end)
end
end)
end)

2 comments
Ok so it works, but only once. How would I change this?
Fixed it