I’m a lil confused on what this means. (Server sided)
-- Services & Modules
local RS = game:GetService("ReplicatedStorage")
local RSS = RS.Storage
local RSE = RSS.RemoteEvents
local StatesFolder = RSE.States
-- Remotes
local TempState = StatesFolder.Temp
local CreateState = StatesFolder.Create
local DestroyState = StatesFolder.Destroy
-- Main Script
TempState.OnServerEvent:Connect(function(Player, State, Duration)
local Char = Player.Character or Player.CharacterAdded:Wait()
local Bool = Instance.new("BoolValue")
Bool.Name = State
Bool.Parent = Char.States
game.Debris:AddItem(Bool, Duration)
end)
CreateState.OnServerEvent:Connect(function(Player, State)
local Char = Player.Character or Player.CharacterAdded:Wait()
local Bool = Instance.new("BoolValue")
Bool.Name = State
Bool.Parent = Char.States
end)
DestroyState.OnServerEvent:Connect(function(Player, State)
local Char = Player.Character or Player.CharacterAdded:Wait()
for i,v in pairs(Char.States:GetChildren()) do
if v.Name == State then
v:Destroy()
end
end
end)
You should try rename this to something else as “Destroy” for instance is used to call to Destroy function and it will found Destroy function instead of remote event named “Destroy”
alternatively you can also do
local DestroyState = StatesFolder:FindFirstChild("Destroy") --It will always finding instance
Hello, I will try to answer your question, but more details about the part that confuses you would have been helpful.
The code listens for events sent by the client to the server using RemoteEvents. In this case, it allows to create a “states” that are directly added to the player’s character.