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

I need a way to be able to when you press "e" it will make a Model disappear and give you 15 coins? [closed]

Asked by 4 years ago

I need a way to be able to when you press "e" it will make a Model disappear and give you 15 coins? My coins are called "Coins"

0
This is a help site NOT a request site! youtubemasterWOW 2741 — 4y

Closed as Not Constructive by youtubemasterWOW and Ziffixture

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
qVoided 221 Moderation Voter
4 years ago

Put a LocalScript into the StarterGui ::

wait()
local UIS = game:GetService("UserInputService")
local leaderstats = game.Players.LocalPlayer:WaitForChild("leaderstats")
local coins = leaderstats.Coins
----- Optional: Change this ------
local key = "E"
local reward = 15
------ Change this -------
local model = workspace.Model

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode[key] then
        coins.Value = coins.Value + reward
        model:Destroy()
    end

end)
Ad
Log in to vote
0
Answered by 4 years ago

Right Here Is What I Concluded:

local Plr = game.Players.LocalPlayer
local model = workspace.Test -- The Model To Hide
local amountofcoins = 15 -- How Many Coins Earned

Plr:GetMouse().KeyDown:Connect(function(Key)
    if Key == "e" then
        model:Destroy()
        Plr.leaderstats.Coins.Value = Plr.leaderstats.Coins.Value +1
    end
end)

Make Sure The Script Is Local!

If You Still Need Help DM Me: Harry_TheKing1#2303