This is what I want to do: there are objects that I can pick up, but to be able to pick them up at any time I was told to use a script module. For this I have made a function in the Script Module which activates my event which causes the object to be picked up. And the script module is linked to a local script, which activates the ModuleScript function when you click on the object to be picked up. But I don’t understand it doesn’t work. Without clicking anywhere I have error messages as if the ModuleScript function had been triggered by itself.
I hope you can help me, thank you. And sorry for my english
Script:
ModuleScript:
local TakeItems = {}
function TakeItems:InT(item)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage.TakeEvent
Event:FireServer(item)
end
return TakeItems
LocalScript:
player = game.Players.LocalPlayer
local TakeItems = require(script.ModuleItemsTake)
for i, v in ipairs(workspace:GetDescendants()) do
if v.ClassName == ("ClickDetector") and v.Name == ("ItemDetector") then
local item = v.Parent
v.MouseClick:Connect(TakeItems:InT(item))
end
end
Message error:
Specify that the error message occurs without me clicking on the object to take. And besides they disappear as if we had taken them