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

Touch is not detected when player is inside the part?

Asked by 4 years ago

Part's CanCollide is false so players can get inside it. But when players are inside, they have not credited the cash. Please help, thank you! <3

local debounce = false

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if debounce == false then
            debounce = true
            player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1
            wait(1)
            debounce = false
        end
    end
end)
0
Are you sure you have passed the argument for player? SilentsReplacement 468 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

It might be because you haven't actually inserted leaderstats into the Player property. Another reason is because you were trying to access not "a" Player, but "the" player - it's character, not the player itself (line 5) For testing purposes, you can change line 5 with this code: "local player = game.Players:WaitForChild("Inciney")".

Ad

Answer this question