so basically i need help figuring out whats not working and how to fix it, every time i go to the part and press “e” nothing happens but what is supposed to happen is it is supposed to disappear and appear on the gui that says "Packages: "
``local player = game.Players:GetPlayerFromCharacter(“Humanoid”)
local part = script.Parent
local bill = script.Parent.BillboardGui
local mouse = player:GetMouse()
mouse.KeyDown:connect(function(key)
if key == “e” and part.Touched == true then
local stats = player:findFirstChild(“leaderstats”)
if stats ~= nil then --If moneyholder exists then
local cash = stats:findFirstChild(“Package”) --Get money
cash.Value = cash.Value + 1 --increase amount of money by the number displayed here (500)
wait(0.1)
part:Destroy()
end
end) ```
In my opinion, I would use :IsKeyDown
for instance this script my dev made:
UserInputService = game:GetService("UserInputService")
plr = script.Parent.Humanoid
while true do
if UserInputService:IsKeyDown(Enum.KeyCode.LeftShift or Enum.KeyCode.RightShift) then
plr.WalkSpeed = 35
else
plr.WalkSpeed = 25
end
wait()
end
if UserInputService:IsKeyDown(Enum.KeyCode.E) then
local stats = player:findFirstChild("leaderstats")
if stats ~= nil then --If moneyholder exists then
local cash = stats:findFirstChild("Package") --Get money
cash.Value = cash.Value + 1 --increase amount of money by the number displayed here (500)
wait(0.1)
part:Destroy()
else
end
end
end) ```
local player = game:GetService("Players").LocalPlayer
local part = script.Parent
local bill = script.Parent.BillboardGui
local UIS = game:GetService("UserInputService")
local mouse = player:GetMouse()
local touched = false
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
touched = true
end)
part.TouchEnded:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
touched = false
end)
UIS.InputBegan:Connect(function(key)
if key.KeyCode = Enum.KeyCode.E and Touched == true then
local stats = player:findFirstChild(“leaderstats”)
if stats ~= nil then --If moneyholder exists then -- these codes are yours
local cash = stats:findFirstChild(“Package”) --Get money
cash.Value = cash.Value + 1 --increase amount of money by the number displayed here (500)
wait(0.1)
part:Destroy()
end
end)
end)