Most solutions I have found online is detecting the value inside the player backpack or rather. Detecting the tool itself with a specific name.
How my game works are players have a tool called Shotgun. This tool has an int Value inside it that increases with every new shotgun you get and its main purpose is determining how many Skulls you get every click. All guns have another value for the price.
All calculations so far are done serverside with a bit of debounce.
local replicaredStorage = game:GetService("ReplicatedStorage")
local remoteData = game:GetService("ServerStorage"):WaitForChild("RemoteData")
local cooldown = 1
replicaredStorage.Remotes.Skull.OnServerEvent:Connect(function(player)
if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end
local debounce = remoteData[player.Name].Debounce
if not debounce.Value then
debounce.Value = true
player.leaderstats.Skulls.Value = player.leaderstats.Skulls.Value + 5 * (player.leaderstats.Rebirths.Value + 1)
wait(cooldown)
debounce.Value = false
end
end)
You can see the "+5" that is in there. What I want to have is a + "Value inside of the currently equipped weapon". I could mention that this script is inside of ServerScriptService.
I want the script to check inside the currently equipped tool for the value named "Skull" that holds the number 5 instead.

1 comment
Thank you. After fibbeling around a bit with your suggestion I got it to work! You've been huge help!