-
What do you want to achieve? I want that when you touch the part this clone a item from the replicated storage into your backpack, and take the “Required Money” from the player.
-
What is the issue? It’s somehow not working, evertime I click the part this happends
-
What solutions have you tried so far? I’ve tried to add the parameter “Player” and call it when the player join, but that didn’t worked, so far.
If is possible, I’d like you guys to tell me what’s wrong, or give me a idea of what can i do to fix this by myself. Thanks and have a good day!
This is the Module
local PlayerReward = {}
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Toolkit = ReplicatedStorage.MainGame.Resources:FindFirstChild("Flash Light")
local RequiredMoney = 5000
local RequiredLevel = 2
---
task.wait(3)
local PlayerStatsFolder = Players:FindFirstChild("leaderstats",true)
function PlayerReward:CheckUser()
local PlayerMoney = PlayerStatsFolder:FindFirstChild("Money")
local PlayerLevel = PlayerStatsFolder:FindFirstChild("Level")
if PlayerMoney.Value >= RequiredMoney and PlayerLevel.Value >= RequiredLevel then
local GiveItem = Toolkit:Clone()
GiveItem.Parent = Players[Players.Name].Backpack
print("Thanks for playing our game! ")
PlayerMoney.Value = PlayerMoney - RequiredMoney
else
return
end
end
return PlayerReward
This is the client framework:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MainGame = ReplicatedStorage:WaitForChild("MainGame")
local Modules = MainGame.Modules
local StarterPack = workspace.StarterPack
local Detector = StarterPack.StarterPackDetector
---
local PlayerReward = require(Modules.PlayerReward)
Detector.Touched:Connect(function(FindHumanoid)
local Humanoid = FindHumanoid.Parent:FindFirstChild("Humanoid")
if Humanoid then
PlayerReward:CheckUser()
Detector:Destroy()
else
return "I'd like to know, what the is touching me."
end
end)