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

my touched script is not working.its supposed to add 1 to an intvalue. why?

Asked by
seikkatsu 110
4 years ago
local tool = game.StarterPack.Tool
tool.Equipped:Connect(function()
    script.Parent.Touched:Connect(function(hit)
        local hum = hit.Parent:FindFirstChild("Humanoid")
        local p = game.Players:GetPlayerFromCharacter(hit.Parent)
        local stats = p:FindFirstChild("leaderstats").Water
        if hum and p and stats then
            stats.Value = stats.Value + 1
        end
    end)
    tool.Unequipped:Connect(function()
        script.Parent.Touched:Connect(function(hit)
            local hum = hit.ParentFindFirstChild
            if hum then
                wait()
            end
        end)
    end)
end)

this is a server script parented to a part it's supposed to add 1 to the "Water" value whenever the part is touched while a certain tool is equipped i don't get it what am i doing wrong

0
on line 13 you missed a colon and parentheses.that might be the issue Inconcinnus 90 — 4y
0
on line 13 you missed a colon and parentheses.that might be the issue Inconcinnus 90 — 4y
0
nope that isn't the issue seikkatsu 110 — 4y
0
does it output any error? If so, what is the error? arondevs 65 — 4y
View all comments (2 more)
0
there's no error seikkatsu 110 — 4y
0
See, the problem here is your are doing game.StarterPack with a server script. When using StarterPack or anything player related, you are supposed to use a local script and connect the 2 using remote events. 20002000sa 83 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

On line 13, you missed a colon and a parentheses... that might fix your issue.

local tool = game.StarterPack.Tool
tool.Equipped:Connect(function()
    script.Parent.Touched:Connect(function(hit)
        local hum = hit.Parent:FindFirstChild("Humanoid")
        local p = game.Players:GetPlayerFromCharacter(hit.Parent)
        local stats = p:FindFirstChild("leaderstats").Water
        if hum and p and stats then
            stats.Value = stats.Value + 1
        end
    end)
    tool.Unequipped:Connect(function()
        script.Parent.Touched:Connect(function(hit)
            local hum = hit.Parent:FindFirstChild()
            if hum then
                wait()
            end
        end)
    end)
end)
0
this isn't the issue seikkatsu 110 — 4y
0
If it isn't sending an error then you most likely dont have a remote event connected which i'd try adding to see if that works. Just2Terrify 566 — 4y
Ad

Answer this question