So I built a soda machine, and what I want it to do is on a button press is spawn a can model in one of the three colors in there at the ‘dispenser’ and have it roll around a bit. (maybe I’ll make it a tool eventually but one thing at a time)
I’m loading a model, so I’m using loadasset, but I’m wondering if there’s a better way to do this. Since it’s. Y’know. Not working. lmao
This is my server script
local canEvent = game.ReplicatedStorage:WaitForChild("CanSpawn")
local machine = workspace:WaitForChild("soda pawp")
--canColors = {1001,330,226}--
--[[local canColor = math.randomseed(tick())
local colorPick = canColors[math.random(1,#canColors)]
]]--
canEvent.OnServerEvent:Connect(function()
local canModel = game:GetService('InsertService'):LoadAsset(4769594297)
canModel.Parent = machine.spawn
print "event sent"
end)
and this is the local script
--[[soda pawp machine; shinyswablu]]--
local machine = workspace:WaitForChild("soda pawp")
local button = machine.button.ClickDetector
local canEvent = game.ReplicatedStorage:WaitForChild("CanSpawn")
button.MouseClick:Connect(function(player)
canEvent:FireServer(player)
end)
I put in a random table with the three colors, but I marked it off as comment to get everything else working, and there’s just, no colors being spawned with it. Is it because I can’t call colors to something that doesn’t exist yet? I had a function under the model being spawned, so since it was after, I thought it’d be okay… Or is it the part I have set as parent?
Everything I’ve seen about loadasset is pre loading, so I’m not sure if this is even the right thing to do lmao. Any advice would be appreciated!