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

How do you make a working gamepass in a local script?

Asked by 4 years ago
Edited 4 years ago

So, I want to make a x2 coins gamepass, but my coin script is in a local script, so I wouldn't be able to use a normal script. Can anybody help me?

local hrp = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local player = game.Players.LocalPlayer
local chicken = false
local Event = game:GetService("ReplicatedStorage").CoinEvents.GoodCoins5

hrp.Touched:Connect(function(hit)
        if hit.Name == "Coin5" then -- If something hits the humanoid, it will see if its name is "Coin"
            if chicken == false then -- If Chicken is false,(which it is), then the code below will run
                chicken = true -- Chicken then becomes true, so if you don't set it back to false, the next coin would not be collected.
                Event:FireServer() -- We are firing this remoteevent to the server, so the whole server can see it
                print('POINTS: ' .. player.leaderstats.Points.Value) -- Optional just to print in the output
                print(hit.Name) -- Optional, again
                hit:Destroy() -- Now destroy the coin
                workspace.CoinSound:Play()
                wait(0.1) -- Wait to ensure the player doesn't get too many points for one coin.
                chicken = false -- We are setting chicken back to false, so the code can run again.
    end
  end
end)
0
It’s pretty easy to convert to a ServerScript. Just provide us with your LocalScript and we can assist you from there. Ziffixture 6913 — 4y
0
Do you want the script in serverscriptservice that defines what will happen when the event fires as well? baldi92102 2 — 4y

Answer this question