I’m not sure how to explain but when I press the specified key and the event fires, it seems to save the input when the requirements are met?
Basically:
- I press the key (leftctrl)
- I switch the teams
- I enable a required boolValue in my character (on the server)
- My character does the actions defined in the script without any input after
Is there something to prevent this?
ServerScript (inside char):
local players = game:GetService("Players")
local char = script.Parent
local humanoid = char:WaitForChild("Humanoid")
local inputEvent = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("ActorInput")
local id1 = 18126945100
local id2 = 18126957847
local id3 = 18126959536
local getDown = ("rbxassetid://"..id1)
local lay = ("rbxassetid://"..id2)
local getUp = ("rbxassetid://"..id3)
local getdown = Instance.new("Animation")
getdown.AnimationId = getDown
local L = Instance.new("Animation")
L.AnimationId = lay
local getup = Instance.new("Animation")
getup.AnimationId = getUp
local animator = humanoid:WaitForChild("Animator")
local GetUpAnim = animator:LoadAnimation(getup)
local LayAnim = animator:LoadAnimation(L)
local GetDownAnim = animator:LoadAnimation(getdown)
local surrendered = false
inputEvent.OnServerEvent:Connect(function(plr, input, mouseInput)
if plr.Neutral then return end
if plr.Team ~= game:GetService("Teams")["Test Subject"] then return end
local inputToUse = string.lower(input)
if inputToUse == "leftcontrol" or "rightcontrol" then
if plr.Character == char then
if plr.Team == game:GetService("Teams")["Test Subject"] then
if char:FindFirstChild("Terminate").Value == true then
local check = char:GetDescendants()
for _, v in pairs(check) do
if v:IsA("Part") then
v.Anchored = true
end
end
if surrendered == false then
humanoid.WalkSpeed = 0
humanoid.JumpHeight = 0
GetDownAnim:Play()
GetDownAnim.Ended:Wait()
surrendered = true
char:FindFirstChild("Terminate").Value = false
LayAnim:Play()
elseif surrendered == true then
LayAnim:Stop()
GetUpAnim:Play()
GetUpAnim.Ended:Wait()
for _, v in pairs(check) do
if v:IsA("Part") then
v.Anchored = false
end
end
humanoid.WalkSpeed = 18
humanoid.JumpHeight = 7.2
surrendered = false
char:FindFirstChild("Terminate").Value = true
end
end
end
end
end
end)
Local Script (inside starterplrscripts):
local UIS = game:GetService("UserInputService")
local event = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("ActorInput")
UIS.InputBegan:Connect(function(input, eve)
if eve then return end
local otherInput = input.UserInputType
event:FireServer(input.KeyCode.Name, otherInput)
end)