Hi! I'm making script which gonna wear player which clicked textbutton and I want it make randomly, I mean to choose randomly clothes and I made this. What is exactly wrong?
This is this script
local ReplicatedStorage = game:GetService("ReplicatedStorage") local EventStorage = ReplicatedStorage.EventStorage local clothing = {game.ReplicatedStorage.EventStorage.ClothingEvent2:FireServer(),game.ReplicatedStorage.EventStorage.ClothingEvent1:FireServer()} script.Parent.MouseButton1Click:connect(function() game.ReplicatedStorage.EventStorage = clothing[math.random(1, 2)] end)
Hey there. Here is the solution to your problem. Hope it helps! :)
-- Assignments like you described, no need to change anything here. local ReplicatedStorage = game:GetService("ReplicatedStorage") local EventStorage = ReplicatedStorage.EventStorage -- Event Referencing local clothing {ReplicatedStorage.EventStorage.ClothingEventA, ReplicatedStorage.EventStorage.ClothingEventB} -- Use the service instead of game.ReplicatedStorage and remove integars from the names of the events -- The function itself local function ChooseRandomCloth() clothing[math.random(1, 2]:FireServer() -- Chooses random event and fires it. end script.Parent.MouseButton1Click:Connect(ChooseRandomCloth)
You cannot fire Remotes from a table. You should only fire it when it has been selected from math.random.