Local script. I’ll see if it does print in the code what you said.
Where is the script located though? A LocalScript
will only work under:
StarterPlayerScripts
StarterCharacterScripts
StarterGui
StarterPack
ReplicatedFirst
edit: nevermind I saw your reply to the other person below
bool and script is inside character. I added the “character added” cause there was something what broke.
You don’t need the character added if it’s a startercharacterscript, just use script.Parent
. You’re checking if the magnitude of the movedirection of the humanoid is greater than 0, which means if they’re moving, are you moving while the script is running?
You are also checking if the value is true
, are you aware of that?
It doesn’t show anything. I’ll try using a remote event.
yeah, I want the value to go true if it can do the action. I know that, that I don’t need to add “character added”, but at the time it just broke when it was script.Parent.
Yes I was moving when the script was running and it still did show the backpack even if I want it to not show when the value is false.
Try using .Heartbeat
for the event instead of .RenderStepped
.
It still does that… I don’t know what to do.
Can you send the entire script?
which one? The server one or the client one?
Both of themmmmmmmmmmmmmm. (chars)
Client:
local runService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerEvent = ReplicatedStorage:WaitForChild("Anti-CampersEvent")
runService.Heartbeat:Connect(function()
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local Hum = character:WaitForChild("Humanoid")
-- local currentTime = tick()
if Hum.MoveDirection.Magnitude > 0 and Hum.WalkSpeed > 0 then
ServerEvent:FireServer()
if script.Parent:FindFirstChild("Status").CanRunAntiCamp.Value ~= false then
-- print("Actually it's soo broken..")
-- print(script.Parent:FindFirstChild("Status").CanRunAntiCamp.Value)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
end
end
end)
Server one:
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local container = script.Parent
local zone = Zone.new(container)
zone.playerEntered:Connect(function(player)
local char = player.Character
local Hum = char:FindFirstChild("Humanoid")
local Place = char:FindFirstChild("Anti-CampersThings")
local LimbHealths = char:FindFirstChild("LimbHealths")
wait(0.5)
local ForceField = Instance.new("ForceField", player.Character)
ForceField.Visible = false
local ForceFieldEffect = workspace:FindFirstChild("PlayerMaterials"):FindFirstChild("Force Field Effect"):FindFirstChild("Effect"):Clone()
char.Status.CanRunAntiCamp.Value = false
LimbHealths.Parent = Place
Hum:UnequipTools()
ForceFieldEffect.Bolts.Enabled = true
ForceFieldEffect.Bubble.Enabled = true
--ForceField.Parent = char:FindFirstChild("Head")
ForceFieldEffect.Parent = char:FindFirstChild("Torso")
end)
zone.playerExited:Connect(function(player)
if player.Character:WaitForChild("Anti-CampersThings"):WaitForChild("LimbHealths") then
local character = player.Character
local Place = character:WaitForChild("Anti-CampersThings")
local LimbHealths = Place:FindFirstChild("LimbHealths")
wait(0.5)
character.Status.CanRunAntiCamp.Value = true
if LimbHealths then
LimbHealths.Parent = character
end
if character:FindFirstChild("Torso"):FindFirstChild("Effect") then
character:FindFirstChild("Torso"):FindFirstChild("Effect").Bubble.Enabled = false
wait(0.3)
character:FindFirstChild("Torso"):FindFirstChild("Effect").Bolts.Enabled = false
end
if character:FindFirstChild("ForceField") then
character:FindFirstChild("ForceField"):Destroy()
end
task.wait(2)
if character:FindFirstChild("Torso"):FindFirstChild("Effect") then
character:FindFirstChild("Torso"):FindFirstChild("Effect"):Destroy()
end
end
end)
The problem is actually that it just doesn’t change for the server and client even tho it shows in explorer, 0 errors and anything. shows just in the explorer and doesn’t react on scripts?
Might be that your event doesn’t have time to run to set the value before you check it.
You may want to try InvokeServer() instead of FireServer()
You can test to see if this is the issue by
local runService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerEvent = ReplicatedStorage:WaitForChild("Anti-CampersEvent")
runService.Heartbeat:Connect(function()
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local Hum = character:WaitForChild("Humanoid")
-- local currentTime = tick()
if Hum.MoveDirection.Magnitude > 0 and Hum.WalkSpeed > 0 then
ServerEvent:FireServer()
Task.Wait(2) --!! WAITING FOR SERVER TO RUN ITS SCRIPT
if script.Parent:FindFirstChild("Status").CanRunAntiCamp.Value ~= false then
-- print("Actually it's soo broken..")
-- print(script.Parent:FindFirstChild("Status").CanRunAntiCamp.Value)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
end
end
end)
If placing the wait fixes the issue then using InvokeServer() will help to wait until you return to resume your local script.
well, that event is to send event that the character moved to run the script deleting the ff. Not the value.
Ok I found somehow the solution. Thanks for the help!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.