Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I am making a simulator and need help on somthing so can you stop by? (read desc)

local remote = game.ReplicatedStorage.Give

remote.OnServerEvent:Connect(function(Player) local plr = Player plr.leaderstats.Sips.Value = plr.leaderstats.Sips.Value +1 end)

that's the code I used for when click you get 1 sips but all the cups when click only give you 1 I am making a Simulator and Need this fixed so if anyone has any other ways to do this or maybe can addon so like I need the tool to be a name idk please help me..

1 answer

I made a basic system where it checks for the name of the tool that the player is holding. If they are holding a tool named Basic then it will give them 1, if they are holding a tool named Advanced then it will give them 5. You can add more items to ToolList by following the same format that Ive done.

local ToolList = { -- Create a table
    {
        ToolName = "Basic",
        GiveAmount = 1
    },
    {
        ToolName = "Advanced",
        GiveAmount = 5
    }
}

function GiveStats(player)
    if player and player.Character then -- Check to make sure the player isn't nil and the player's character exists
        local EquippedTool = player.Character:FindFirstChildOfClass("Tool") -- Find the tool the player has equipped
        if EquippedTool then -- Make sure the player actually has a tool
            for index, Tool in pairs(ToolList) do -- Iterate over all the items in ToolList
                if Tool.ToolName == EquippedTool.Name then -- If the tool is the same as the one the player is holding...
                    return Tool.GiveAmount -- Return the amount corresponding to the tool
                end
            end
        end
    end
    return 0 -- If the tool name was not found then just return 0
end

local remote = game:GetService("ReplicatedStorage").Give

remote.OnServerEvent:Connect(function(Player)
    Player.leaderstats.Sips.Value = Player.leaderstats.Sips.Value + GiveStats(plr) -- Adding the value that the function returns for that player
end)

3 comments

0

Thank you so much but I just leave the script in workSpace?

0

Workspace or replicatedstorage, pretty much anywhere is good

0

Hey I need you help the script did not work I added an tool Called Basic and when I clicked I got nothing. Please reply. @thatwalmartman

This discussion is preserved as it was. New answers, comments, and votes are closed.