Hi so i am a making a script where if a player touches a part it takes the value of 'souls' and adds it to the 'Qu' (currency) but even though the value of 'souls' is greater then 1 in the leader board the script returns the value as 0
heres the code:
local sellPad = script.Parent["Sell Parts"].SellPart
local quValueGui = game.StarterGui.quGui.quValueGui
local soulsValueGui = game.StarterGui.soulsGui.soulsValueGui
sellPad.Touched:Connect(function(hit)
local H = hit.Parent:FindFirstChild("Humanoid")
if H then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local leaderstats = player:WaitForChild("leaderstats")
local souls = leaderstats.Souls
local qu = leaderstats.Qu
if souls.Value >= 0 then
print(souls.Value)
qu.Value = souls.Value + qu.Value
quValueGui.Text = qu.Value
end
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 34956109) then
if souls.Value > 0 then
qu.Value = souls.Value + qu.Value * 2
quValueGui.Text = qu.Value
end
end
end
end
end)
this is the script for updating the values everytime u click:
local cooldown = false
game:GetService("UserInputService").InputBegan:Connect(function(input, engine_processed) if engine_processed then return end
local player = game.Players.LocalPlayer
local soulsGui = game.Players.LocalPlayer.PlayerGui.soulsGui.soulsValueGui
local leaderstats = player:WaitForChild("leaderstats")
local souls = leaderstats.Souls
local qu = leaderstats.Qu
local values = {
game.Workspace.coffinValues.woodCoffin.Value,
game.Workspace.coffinValues.ironCoffin.Value,
game.Workspace.coffinValues.goldCoffin.Value
}
if cooldown == false then
if input.UserInputType == Enum.UserInputType.MouseButton1 then
cooldown = true
soulsGui.Text = soulsGui.Text + values[1]
souls.Value = souls.Value + values[1]
wait(0.5)
cooldown = false
end
end
if cooldown == false then
if input.UserInputType == Enum.UserInputType.Touch then
cooldown = true
soulsGui.Text = soulsGui.Text + values[1]
souls.Value = souls.Value + values[1]
wait(0.5)
cooldown = false
end
end
end)
wait(2)
cooldown = false
the selling pad works when i increase the value by stepping on a part but when i click and it increases it always returns the value as 0 even though the value is more than 1
the increase by clicking script is a local script and the selling pad is a server script
