I have a ShopGui and the main script in there is working and Firing a RemoteEvent and the script for the Event is in ServerScriptService. The shop item is in the gui in a folder. Here is the main script:
--// Variables
local sgui = script.Parent.Parent
local misc = sgui.Misc
local guis = sgui.Guis
local scripts = sgui.Scripts
local values = sgui.Values
local I1 = guis.Trails.Item1:WaitForChild("BuyT")
local I2 = guis.Trails.Item2:WaitForChild("BuyT")
local I3 = guis.Trails.Item3:WaitForChild("BuyT")
local I4 = guis.Trails.Item4:WaitForChild("BuyT")
local I5 = guis.Trails.Item5:WaitForChild("BuyT")
local I6 = guis.Trails.Item6:WaitForChild("BuyT")
local I7 = guis.Trails.Item7:WaitForChild("BuyT")
local I8 = guis.Trails.Item8:WaitForChild("BuyT")
local I9 = guis.Trails.Item9:WaitForChild("BuyT")
local IX = guis.Trails.ItemX:WaitForChild("BuyT")
local bt = game:GetService("ReplicatedStorage").BuyTrail
local mb = game:GetService("ReplicatedStorage").MoveBlur
--// Code
I1.MouseButton1Click:Connect(function()
bt:FireClient("Trail1")
end)
I2.MouseButton1Click:Connect(function()
bt:FireClient("Trail2")
end)
I3.MouseButton1Click:Connect(function()
bt:FireClient("Trail3")
end)
I4.MouseButton1Click:Connect(function()
bt:FireClient("Trail4")
end)
I5.MouseButton1Click:Connect(function()
bt:FireClient("Trail5")
end)
I6.MouseButton1Click:Connect(function()
bt:FireClient("Trail6")
end)
I7.MouseButton1Click:Connect(function()
bt:FireClient("Trail7")
end)
I8.MouseButton1Click:Connect(function()
bt:FireClient("Trail8")
end)
I9.MouseButton1Click:Connect(function()
bt:FireClient("Trail9")
end)
IX.MouseButton1Click:Connect(function()
bt:FireClient("TrailX")
end)
And here is the event script:
local bt = game:GetService("ReplicatedStorage").BuyTrail
local mb = game:GetService("ReplicatedStorage").MoveBlur
bt.OnClientEvent:Connect(function(player, trail)
print("Attempting To Buy Trail")
local t = player.PlayerGui.TrailShop:WaitForChild("Trails"):FindFirstChild(trail):Clone()
player.CharacterAdded:Connect(function(char)
t.Parent = char.HumanoidRootPart
local a0 = Instance.new("Attachment",char.Head)
a0.Name = "Attach0"
local a1 = Instance.new("Attachment",char.HumanoidRootPart)
a1.Name = "Attach1"
t.Attachment0 = a0
t.Attachment1 = a1
end)
end)
mb.OnServerEvent:Connect(function()
end)
I get an error when I click the button that says "Unable to cast value to Object" for whatever line the button I clicked on for example if I clicked the first one it would be on line 24.
I'm really not sure what is happening as I am new to FE scripting. Some help would be appreciated. And if you could test it before you post it to make sure it works.
Take this if you need a better reference: https://www.roblox.com/library/1111083460/Shop-Need-Help

3 comments
Oh, i thought it was the other way around, like the first script is local and second script is server. Well anyways, a client cannot make attachments in the first place.
Could you take the linked model and fix it and re upload and link it here or no?
I have updated my answer!