I need help with a model

Guys, I would need help with a small model (box), and the things I need help with is:

  • When you click on a part of a model, what do I write in script like function(OnClick) or something (i forgot).
  • What do I write when I want for system to randomize stuff that could appear in a model? For example; 50% for hotdogs to spawn and 50% for paper to spawn.
  • What do I write in script when I open the box and it will print for example system spawned hotdogs inside the box and it should print “ItzCrime_bruh found hotdogs in a box!” (just it should say the user who opened box and who found hotdog)

please help

Simple way of doing it


function DoSomething()
local Rmath = math.random(1,2) -- Should be a 50%

if Rmath == 1 then
local A = Hotdog:Clone();  A.Parent = Model
else
local B = Paper:Clone();  B.Parent = Model
end
end

Model.Part.ClickDetector.MouseClick:Connect(DoSomething)

Here’s a better way of doing it:

function DoSomething()
  local Rmath = math.random(1,2) -- Should be a 50%
  local model
  if Rmath == 1 then
    model = Hotdog:Clone()
  else
    model = Paper:Clone()
  end
  model.Parent = Model
end

Model.Part.ClickDetector.MouseClick:Connect(DoSomething)

I know, I rather not provide anything more advanced due to the rules of #help-and-feedback:scripting-support

Good but what about the function like what do I put in function like when I click e

1 Like
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input)
  if input.KeyCode == Enum.KeyCode.E then
    --u pressed e
  end
end)

also make sure this is all in a local script

edit: this stuff is extremely easy to search up and learn how to do. After you start doing that, you wouldn’t have to make much dev forum posts