What do you want to achieve?
Whenever the person click on the part, a gold pops up and the person is able to touch it and increase his gold reserve in the leaderboard.
What is the issue?
The code doesn’t seem to work.
What solutions have you tried so far?
Didn’t find anything that could help me on the Developer Hub, so please respond to me as soon as possible.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local part = workspace.test
local Click = part.ClickDetector
local gold = ReplicatedStorage.gold
local function clicked()
local goldd = gold:Clone()
goldd.Position = part.Position
goldd.Parent = workspace
end
local function goldtouched(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
local Gold = hit.Parent.leaderstats.Gold
Gold.Value = Gold.Value + 1
end
end
Click.MouseClick:Connect(clicked)
goldd.Touched:Connect(goldtouched)
Well, I did the same and didnt work. I changed script so it looks different, but does the same
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local part = workspace.test
local Click = part.ClickDetector
local gold = ReplicatedStorage.gold
Click.MouseClick:Connect(function()
local goldd = gold:Clone()
goldd.Position = part.Position
goldd.Parent = workspace
goldd.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
print("found humanoid")
local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if Player then
print("found player")
local Gold = Player:FindFirstChild("leaderstats").Gold
if Gold then
print("found gold")
Gold.Value = Gold.Value + 1
end
end
end
end)
end)