for i,v in pairs(char:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:Connect(function(hit)
print(DataEvent:Invoke("Get", "GridCells", tostring(hit.Parent.Name))) -- HERE
print("wer")
if hit:IsA("BasePart") and hit.Parent.Parent.Name == "Grid" and GridModule.GetState(tonumber(hit.Parent.Name)) == true then
print(GridModule.GetState(tonumber(hit.Parent.Name)))
ChangeBtn(true)
elseif hit:IsA("BasePart") and hit.Parent.Parent.Name == "Grid" and GridModule.GetState(tonumber(hit.Parent.Name)) == false then
print(hit.Parent.Parent.Name)
ChangeBtn(false)
end
end)
end
end
I have no idea what I’m doing wrong here but the script just breaks when I invoke a bindable function. The Touched events don’t work and the output is empty. I’m not sure what I’m doing wrong here.
This is where I receive the invoke
local ServerData = {
["GridCells"] = {}
}
local AddData = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("ServerData")
AddData.OnInvoke = function(action, category, name, data)
if action == "Add" then
ServerData[category][name] = data
elseif action == "Get" then
print("Received")
return ServerData[category][name]
end
end