Speed Modifier Issue

Recently I tried to make a “speed modifier” so anyone who has a Game Pass can use. I actually have some issues that I’m unsure of how to fix.

  1. I don’t know how to make a UI only visible to those who own the Game Pass needed/
  1. The speed isn’t showing on the counter.

I’m not a scripter or know how to code, but I need some help.

Script:

Counter issue:

Uploading: Screen Recording 2021-05-03 at 19.23.48.mov…

As you can see in the video, the counter isn’t updating and the number stays at 16.

1 Like

Firstly, you should ensure your references to property names are correct, otherwise your code will throw an error. If the references to the objects in your code are correct, the following should work:

local label = script.Parent.Parent.TextLabel
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait() -- wait for the player's character to load

script.Parent.MouseButton1Click:Connect(function()
    character.Humanoid.WalkSpeed += 1 -- increase the walkspeed by 1
    label.Text = tostring(character.Humanoid.WalkSpeed) -- set the text of the label to the walkspeed
end)
1 Like

WOW!! Thanks it works! I still have one “issue” though… :sweat_smile:

I want the UI visible to those who a Game Pass.

Here’s some articles:

Hope this helps.

I wouldn’t understand as I’m not a coder. :cry:

Try this:

local id = --gamepass id here

game.Players.PlayerAdded:Connect(function(player)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id) then
--code here
end

end

You should never be setting the speed on the client. Instead, fire a remote event and have it assigned there.

1 Like

I would usually use a remote for things like this though I’m honestly unsure if it’s necessary in this scenario because you can make modifications to the player’s character on the client and it will replicate to the server. Not really sure what’s better - setting it using a remote or setting it from the client, though I know it’s an important practice not to trust the client so I’d go with the solution of updating the WalkSpeed on the server.