Hello,
for a bit of context here: Im trying to make a trails handler that takes in a trail and throws it in the torso, that works!
What doesnt work or where did i go in the wrong? Well, printing out self throws an error: ServerScriptService.TrailHandler:50: attempt to concatenate string with nil
And yes im 100% sure im using the correct opperators.
My code in modulescript:
local trail = {}
trail.__index = trail
local name = "Trail_Attachment"
function trail.new(char:Model)
if char.Torso and char.Torso:FindFirstChild(name) then Destroy(char) end
local self = setmetatable({}, trail)
local torso:Part = char.Torso
local a1 = Att(torso)
local a2 = Att(torso)
a1.WorldPosition = torso.Position + Vector3.new(0, 1.4, 0)
a2.WorldPosition = torso.Position - Vector3.new(0, .2, 0)
self.att1 = a1
self.att2 = a2
end
function trail:Make(trail:Trail, char:Model)
if trail == nil then
Destroy(char)
end
local torso:Part = char and char.Torso
local Clone = trail:Clone()
Clone.Parent = torso
--Clone.Attachment0 = self.att1
--Clone.Attachment1 = self.att2
print("self hier att1 is: " .. self.att1) -- here it throws error
print("self hier att2 is: " .. self.att2)
end
return trail
Remember that everything works, i just need to know why the print will throw an error
Still returns nil, do you know why?
Current server:
local remote = game.ReplicatedStorage.Remotes.Trail
local handler = require(script.Parent.TrailHandler)
local trails = game.ReplicatedStorage.Trails
remote.OnServerEvent:Connect(function(plr, trail)
local char = plr.Character
local newTrail = handler.new(char)
handler:Make(trail, char)
end)
The client one sending remote:
local frame = script.Parent
local buttons = frame:GetChildren()
local remote = game.ReplicatedStorage.Remotes.Trail
for i, button in buttons do
if button and button.Parent and button:IsA("GuiButton") then
button.Activated:Connect(function()
local trail = button and button.Trail
remote:FireServer(trail.Value)
end)
end
end
Trail in the client one is a obj value referring to the trail