I am trying to use a variable (TimesFound2) from my script RandMove (1) in my other script Leaderboard (2)
local RandMove = {}
Increment = 1
TimesFound1 = 0
Part = game.Workspace.Brick1
TimesFound2 = 0
local debounce = false
function RandMove.RandMove(hit)
if debounce == false then
debounce = true
Part.Position = Vector3.new(math.random(0, 100), 5, math.random(0, 100))
TimesFound1 = TimesFound1 + Increment
TimesFound2 = TimesFound1
print(TimesFound2)
wait(1)
debounce = false
end
end
Touched = Part.Touched:Connect(RandMove)
return RandMove
RandMove = require("RandMove")
function Score(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("NumberValue")
money.Name = "Money"
money.Parent = leaderstats
money.Value = RandMove.TimesFound2
end
game.Players.PlayerAdded:Connect(Score)
Score()
It is returning the error: Attempted to call require with invalid argument(s).

4 comments
How can i fix this?
no no no the require you have to pass the module script object into the parameter
also do the touched event inside the local script and make sure to do randmove.randmove
Could you post an answer, and include the edits do i can see what you mean?