Everything seems to work, it just won't change the value's number whenever a ball hits it.
ModuleScript:
local gamescript = {} function gamescript.addscore(value) value = value + 1 end return gamescript
Script:
local SSS = game:GetService("ServerScriptService") local GameScript = require(SSS:WaitForChild("GameScript")) local Values = workspace.Values local Team1Value = Values:FindFirstChild("Team1") local part = script.Parent local debounce = true part.Touched:Connect(function(hit) if hit.Name == "Ball" and debounce then debounce = false print("Ball Found") GameScript.addscore(Team1Value.Value) wait(1) debounce = true end end)
Please help.
Thanks,
LukeGabrieI
REMEMBER, NOT SEND .Value ONLY THE OBJECT! OR YOU GET ERROR ON EDIT!
Try to add .Value in ModuleScript
Example:
local a = {} function a.add(v) v.Value = v.Value + 1 end return a
and on your touch script not send Value only the IntValue(or NumberValue)
Here is fixed your script:
-- TOUCH -- local SSS = game:GetService("ServerScriptService") local GameScript = require(SSS:WaitForChild("GameScript")) local Values = workspace.Values local Team1Value = Values:FindFirstChild("Team1") local part = script.Parent local debounce = true part.Touched:Connect(function(hit) if hit.Name == "Ball" and debounce and Team1Value ~= nil then -- i added Team1Value ~= nil for no get errors on try to find Team1 debounce = false print("Ball Found") GameScript.addscore(Team1Value) -- I only send the Object wait(1) debounce = true end end)
------------------
SEPARATOR
------------------
-- MODULE SCRIPT -- local gamescript = {} function gamescript.addscore(value) value.Value = value.Value + 1 -- Here i added .Value for change the value end return gamescript
Hope it helped :)