okay so i made this sell script but it wont work i used the print to detect the error but it still wont work can some one help me?




local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvents = ReplicatedStorage.RemoteEvents
local Sold = RemoteEvents.ItemSold

local Debounce = false

script.Parent.Touched:Connect(function(hit)
    print("Player Touched Part")
     if hit.Parent:FindFirstChild("Humanoid") then
        local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if Player.PlayerStats.CurrentValue.Value > 0 then
            if Debounce == false then
                Debounce = true
                Sold:FireClient(Player, Player.PlayerStats.CurrentValue.Value)
                Player.PlayerStats.Coins.Value = Player.PlayerStats.Coins.Value + Player.PlayerStats.CurrentValue.Value
                Player.PlayerStats.CurrentValue.Value = 0
                wait()
                Debounce = false
            end
        end
    end
end)

2 comments

0

there's nothing wrong with the script itself, except you have to account for a couple of things. 1. you should use :WaitForChild() for the RemoteEvents variable and the Sold variable. 2. you need to check if Player exists before utilizing it in line 10

0

i did both thoos things it wont work,also else there would be a error there is no error