Hello, I finished writing this only for me to realize I'm not logged in when I clicked ask question so sorry if this seems a bit rushed but I am making 2 moves where when I press Q while having my mouse on the target I would be welded and teleported to them giving the illusion that im controlling them and the second move where when I press e while having my mouse over a target it would swap our positions it was working fine until I wanted to make it so that the victim being controlled wont be able to use moves when he is being controlled so I added a script that would add a bool value and when he gets controlled it would set it to true but when I added that and a few things to my scripts so it would detect if the bool is true or false it wont even work anymore, I put some print commands to see where is when it broke because it wont give any errors and it seems to break at the fire client part I dont really understand fireclient much so if im doing anything wrong with the fire client please let me know --output 1st. Got Passed Local script Controlled verify!, 2nd. Remote Event Call Received!, 3rd. Got passed character verify, 4th. Got passed Controlled Check!, 5th. Called Client Event! -- end of output It would say that it called the client but the client wont respond anything im doing wrong?
script to insert bool value (server script)
wait()
local char = script.Parent
wait()
local controlCheck = Instance.new("BoolValue")
controlCheck.Name = "ControlledCheck"
controlCheck.Value = false
controlCheck.Parent = char
wait(0.5)
script:Destroy()
script to check if player is being controlled only called when he uses a move (server script)
game.ReplicatedStorage.Remotes.Check.CheckControl.OnServerEvent:Connect(function(plr, Remote)
print("Remote Event Call Received!")
if plr.Character then
print("Got passed character verify")
local ControlledCheck = plr.Character:WaitForChild("ControlledCheck",5)
if ControlledCheck.Value == false then
print("Got passed Controlled Check!")
game.ReplicatedStorage.Remotes.Check.CheckControl:FireClient(plr,false,Remote)
print("Called Client Event!")
elseif ControlledCheck.Value == true then
print("Failed Controlled Event")
game.ReplicatedStorage.Remotes.Check.CheckControl:FireClient(plr,true,Remote)
print("Called failed event")
end
end
end)
local script for the keycode and firing events
local players = game:GetService("Players")
local plr = players.LocalPlayer
local mouse = plr:GetMouse()
local Controlling = false
local char = plr.Character or plr.CharacterAdded:Wait()
local ControlledCheck = char:WaitForChild("ControlledCheck",60)
--[[mouse.Button1Down:Connect(function()
local target = mouse.Target
if target ~= nil then
if Controlling == true then
Controlling = false
game.ReplicatedStorage.Remotes.UnControl:FireServer()
elseif target.Parent:FindFirstChild("Humanoid") ~= nil and Controlling == false then
Controlling = true
game.ReplicatedStorage.Remotes.Control:FireServer(target, false, plr.Character.Humanoid.MaxHealth, plr.Character.Humanoid.Health)
end
end
end)]] -- previous code that was scratched
--[[
1 = UnControl Event
2 = Control Event
3 = Swap Event
]]
game:GetService("UserInputService").InputBegan:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.Q then
local target = mouse.Target
if target ~= nil then
if Controlling == true then
if ControlledCheck.Value == false then
print("Got passed local script verify for UnControl")
game.ReplicatedStorage.Remotes.Check.CheckControl:FireServer(1)
game.ReplicatedStorage.Remotes.Check.CheckControl.OnClientEvent:Connect(function(Result,Remote) -- prevent person from using moves when being controlled
if Result == false and Remote == 1 then
Controlling = false
print("Executed UnControlling victim remote")
game.ReplicatedStorage.Remotes.UnControl:FireServer(plr)
print("Executed uncontrolling victim now")
end
end)
end
elseif --[[target.Parent:FindFirstChild("Humanoid") ~= nil and ]]Controlling == false then
if ControlledCheck.Value == false then
print("Got Passed Local script Controlled verify!")
game.ReplicatedStorage.Remotes.Check.CheckControl:FireServer(plr, 2)
game.ReplicatedStorage.Remotes.Check.CheckControl.OnClientEvent:Connect(function(Result,Remote) -- prevent person from using moves when being controlled
if Result == false and Remote == 2 then
Controlling = true
print("Executing control victim remote!")
game.ReplicatedStorage.Remotes.Control:FireServer(target, false, plr.Character.Humanoid.MaxHealth, plr.Character.Humanoid.Health)
print("Executed controlling victim now")
end
end)
end
end
end
elseif Key.KeyCode == Enum.KeyCode.E then
local target = mouse.Target
if target ~= nil then
print("Got passed ~= nil")
if target.Parent:FindFirstChild("Humanoid") ~= nil then
print("Got Passed Humanoid ~= nil")
if Controlling == true then
print("Got passed controlling")
if ControlledCheck.Value == false then
print("Firing Remote Event")
game.ReplicatedStorage.Remotes.Check.CheckControl:FireServer(plr,3)
game.ReplicatedStorage.Remotes.Check.CheckControl.OnClientEvent:Connect(function(Result,Remote) -- prevent person from using moves when being controlled
if Result == false and Remote == 3 then
game.ReplicatedStorage.Remotes.Swap:FireServer(plr,target)
end
end)
end
end
end
end
end
end)

3 comments
Hello I have tried your answer and it seemed to have fixed the control script but the swap script is still broken I will try to figure out how to fix that myself tho thank you for your help!
Figured out how to fix the swap it was just a line of code that was only meant to be in the control check
No problem