I wan’t my script to be functional and working. But it doesn’t work after firing a client with remote events. There was no errors too.
Server Script:
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local debounce1 = false
local debounce = false
local CollectionService = game:GetService("CollectionService")
local KillParts = CollectionService:GetTagged("KillPart")
local TeleportLobbyParts = CollectionService:GetTagged("TeleportLobbyPart")
local SpinParts = CollectionService:GetTagged("Spin")
-- Portal touching
workspace.Lobby.Portal.trigger.Touched:Connect(function(hit)
local Randomchallenge = math.random(1, #ReplicatedStorage.RemoteEvents.Challenges:GetChildren())
local RandomObby = math.random(1, #ServerStorage.Obbies:GetChildren())
-- Delay
if not debounce1 then
debounce1 = true
if hit.Parent:FindFirstChild("Humanoid") then
local char = hit.Parent
local plr = game.Players[char.Name]
hit.Parent = char
ReplicatedStorage.RemoteEvents.DisableControls:FireClient(plr)
local Obby = plr:WaitForChild("stats").Obby
local Challenge = plr:WaitForChild("stats").Challenge
local Chances = plr:WaitForChild("stats").Chances
Chances.Value = 3
--Randomizing and getting the results in values
Challenge.Value = ReplicatedStorage.RemoteEvents.Challenges:GetChildren()[Randomchallenge].Name
Obby.Value = ServerStorage.Obbies:GetChildren()[RandomObby].Name
-- Teleporting to the random obbies
ServerStorage.Obbies:FindFirstChild(Obby.Value).Parent = workspace.Obbies
ReplicatedStorage.RemoteEvents.TeleportTouched:FireClient(plr)
char.HumanoidRootPart:PivotTo(workspace.Obbies:WaitForChild(Obby.Value).Teleport.CFrame)
ReplicatedStorage.RemoteEvents.EnableControls:FireClient(plr)
-- Running the challenges
ReplicatedStorage.RemoteEvents.Challenges:FindFirstChild(Challenge.Value):FireClient(plr)
wait(0.7)
debounce1 = false
end
end
end)
Local Script:
local Controls = require(Player.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
ReplicatedStorage.RemoteEvents.DisableControls.OnClientEvent:Connect(function()
Controls:Disable()
end)
ReplicatedStorage.RemoteEvents.EnableControls.OnClientEvent:Connect(function()
Controls:Enable()
end)
Note: Those are the most important parts of the scripts.
Thanks a bunch!