Now, the issue seems to be that Client to Client doesn’t work, but I need to interact with the gui somehow so how would I do something like this?
wait(1)
--\\ Variables-Players //--
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")
--\\ Animation-Variables //--
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://"
--\\ Services //--
local UIS = game:GetService("UserInputService")
local Event = game.ReplicatedStorage.Meditation
local gui = Player:WaitForChild("PlayerGui"):WaitForChild("TheMeditations") --wait for objects
--\\ Debouncing Variables //--
local Enabled = false
UIS.InputBegan:Connect(function(Input, Processed, IsTyping)
if not IsTyping then
if Processed then
return
end
if Input.KeyCode == Enum.KeyCode.M then
if Enabled == true then return end
if Enabled == false and gui.Enabled == false then
Enabled = true
gui.Enabled = true
Event:FireClient(Input)
end
end
end
end)
In that case, you might wanna consider using a Remote Function. Remote Functions send a message to the server, then returns the result back to the client.
Remote functions can be fired from the client or the server, just like remote events. They fire to the server, then return the result back to the client, or vice versa. Here is an example where the client tells the server to make a part, then returns the part back to the client:
-- Server Script
local ReplicatedStorage = game.ReplicatedStorage
local RemoteFunction = ReplicatedStorage.Meditate -- The Remote function
local function MakePart(Player, Shape) -- Make sure to have the Player parameter
local Part = Instance.new("Part", workspace)
Part.Name = Player.Name .. "'s Part"
Part.Size = Vector3.new(2,2,2) -- All these properties will show on the server
Part.Position = Vector3.new(0,5,0)
Part.Shape = Shape
return Part -- Make sure to return the object you want the client to edit!
end
RemoteFunction.OnServerInvoke = MakePart -- Whenever function is called, run the function
-- Local Script
wait(5)
local ReplicatedStorage = game.ReplicatedStorage
local RemoteFunction = ReplicatedStorage.Meditate -- The remote function
local NewPart = RemoteFunction:InvokeServer(Enum.PartType.Block) -- The parameters that the server will get
NewPart.Color = Color3.fromRGB(255,0,0)
NewPart.Size = Vector3.new(5,5,5) -- These properties will only show on the client
NewPart.Shape = Enum.PartType.Cylinder
This is the main benefit of using a Remote Function. It runs a server-sided function, and then you can edit it further on the client, without others seeing those changes.
I still have a question. If I wanted to toggle it, such as something like this
M Toggles the Meditation script (Local Script) → The event happens on the server (Even though I don’t everyone to see the idk the work around) → ??? (Local Script) what is meant to happen at that point of the script?
I plan to use it for a form of progression, each time the ball movement stops, it’ll update in leaderstats as exp, and continue moving around until the exp requirement is fulfilled.