#better solution then this?

1 messages · Page 1 of 1 (latest)

stoic saddle
#
--[[
Author: Zyos
Date: 06/19/2025 DD/MM/YY
Description: Handles the player practice on the Client
]]

--Services
local ServerScriptService = game:GetService("ServerScriptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

--Events
local Events = ReplicatedStorage:WaitForChild("Events")
local BindableEvents = Events:WaitForChild("BindableEvents")

local fOnKeyboard = BindableEvents:WaitForChild("UserInputService"):WaitForChild("f")

--Variables
local player = Players.LocalPlayer
local practice = player:WaitForChild("invisiblestats"):WaitForChild("practice")
local tools = ReplicatedStorage:FindFirstChild("Tools")

--Main

local function enablePractice()
    print("enable practice")
    local noclip = tools:FindFirstChild("Noclip"):Clone()
    
    noclip.Parent = player.Backpack
    
    while practice.Value do
        task.wait()
        fOnKeyboard.Event:Connect(function()
            print("aight")
        end)
    end
end

local function disablePractice()
    print("disable practice")
    local noclip = player.Backpack.Noclip or player.Character.Noclip
    noclip:Destroy()
    
    local root = player.Character.HumanoidRootPart
    local humanoid = player.Character.Humanoid
    humanoid.PlatformStand = false
    root.Anchored = false
end

practice.Changed:Connect(function()
    if practice.Value then
        enablePractice()
        return
    end
    
    disablePractice()
end)
#

wait thats kinda ass

#

what i did

#

anyways im listening on the client to a BoolValue which the server changes to activate like a practice tool, is there any better solution cause what I dont understand is wehn the server sets the value to true and then the .Changed triggers it sometimes detects false

#
--[[
Author: Zyos
Date: 06/19/2025 DD/MM/YY
Description: Handles the player practice on the Server
]]

-- Services
local ServerScriptService = game:GetService("ServerScriptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--Events
local Events = ReplicatedStorage:WaitForChild("Events")
local RemoteEvents = Events:WaitForChild("RemoteEvents")

local pEvent = RemoteEvents:WaitForChild("UserInputService"):WaitForChild("p")

--Modules
local Modules = ServerScriptService:WaitForChild("Modules")

local playerService = require(Modules:WaitForChild("playerService"))

--Main
pEvent.OnServerEvent:Connect(function(plr)
    local practiceDebounce = plr.debounces.practiceDebounce
    if practiceDebounce.Value then return end
    practiceDebounce.Value = true
    
    playerService:plrChangePracticeState(plr)
    playerService:plrCFrameToCheckpoint(plr, CFrame.new(0,0,0))
    
    task.spawn(function()
        task.wait(2)
        practiceDebounce.Value = false
    end)
end)

this is the server side it just changes the value wehn the player presses P