local button = script.Parent
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = 0
--game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Jumppower = 0
repeat wait() until workspace.CurrentCamera
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = (workspace.ok.CFrame + Vector3.new(0, 0, 10))
wait(5)
button:TweenPosition(UDim2.new(0.5,0,0.77,0),"Out","Linear",1,true)
button.MouseButton1Click:connect(function(click)
button.Transparency = 1
script.Parent.Parent.ImageLabel.Visible = false
button.UIStroke.Transparency = 1
button.TextLabel.Transparency = 1
local Sound = game:GetService("SoundService").Sound
if not Sound.IsLoaded then
Sound.Loaded:Wait()
end
Sound:Play()
Sound.Ended:Wait()
end)
And a serverscript in workspace (in a part)
local TeamChecker = script.Parent
TeamChecker.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
print("touched works")
local Tycoons = game.Workspace["Zednov's Tycoon Kit"].Tycoons
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
for _,child in pairs(Tycoons:GetChildren()) do
if child.Owner.Value == nil and player.Team == game.Teams['For Hire'] then
print("child found")
player.TeamColor = child.TeamColor.Value
child.Owner.Value = player
player.RespawnLocation = child.Essentials.Spawn
player:LoadCharacter()
print("before break")
break
end
end
wait(0.1)
end
end)
I want that if the button is pressed the if statement in the serverscript is true means all the content can be executed then. But if the button wasn’t pressed yet, I want that all the things arent getting executed (until its pressed)
How would I do that? Remotevenets? If yes, how would that look?
I am confused to what exactly you are hoping to achieve, are you attempting to change a value from the client and catch it on the server? If so then, personally, I would use RemoteEvents.
local button = script.Parent
local event = game:GetService("ReplicatedStorage").RemoveEvent
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = 0
--game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Jumppower = 0
repeat wait() until workspace.CurrentCamera
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = (workspace.ok.CFrame + Vector3.new(0, 0, 10))
wait(5)
button:TweenPosition(UDim2.new(0.5,0,0.77,0),"Out","Linear",1,true)
button.MouseButton1Click:connect(function(click)
button.Transparency = 1
script.Parent.Parent.ImageLabel.Visible = false
button.UIStroke.Transparency = 1
button.TextLabel.Transparency = 1
local Sound = game:GetService("SoundService").Sound
if not Sound.IsLoaded then
Sound.Loaded:Wait()
end
Sound:Play()
Sound.Ended:Wait()
event:FireServer()
end)
Server:
local TeamChecker = script.Parent
local event = game:GetService("ReplicatedStorage").RemoteEvent
TeamChecker.Touched:Connect(function(hit)
local function Clicked()
if hit.Parent:FindFirstChild("Humanoid") then
print("touched works")
local Tycoons = game.Workspace["Zednov's Tycoon Kit"].Tycoons
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
for _,child in pairs(Tycoons:GetChildren()) do
if child.Owner.Value == nil and player.Team == game.Teams['For Hire'] then
print("child found")
player.TeamColor = child.TeamColor.Value
child.Owner.Value = player
player.RespawnLocation = child.Essentials.Spawn
player:LoadCharacter()
print("before break")
break
end
end
wait(0.1)
end
end
event.OnServerEvent:Connect(Clicked)
end)
What @Leo_carltheguwapo said, you want to put the RemoteEvent in a place where both the server and client can access it, for example ReplicatedStorage. Then to fire a RemoteEvent you do: :FireServer() if it is a LocalScript and :FireClient() if it is a ServerScript. Then to catch an event you do [Event].OnClientEvent:Connect() for the client and [Event].OnServerEvent:Connect() for the server. Roblox has a page talking all about this.