hi I need help my localscript does not work what I want it to do is: if a player touches a block that block activates the value fight and after that
a local script if game.players.localscript.backpack.Folder (it’s the folder where I keep the game values). value doesn’t matter if it’s true do such a thing and to see if it worked use a print
local script:
local folder = game.Players.LocalPlayer.Backpack
local Player = game.Players.LocalPlayer
if folder.Folder.FIGHT == “true” then
print(“test”)
end
when i touch the block it works and the value fight is activated but then i get this error
Backpack is not a valid member of Player “Players.localplayer”
If you cannot access a value in backpack or the backpack in a local script, can you help me explaining how I should do something similar?
local Players = game:GetService("Players")
local Backpack = Players.LocalPlayer:WaitForChild("Backpack")
if Backpack.Folder.FIGHT then
print("test")
end
There’s no way this does not work unless I am out of my mind and Backpack actually does not exist.
yes is a local script I tried moving the local script to another place and it worked but when I have the value of fight in true
the print(“test”) doesn’t work
local Players = game:GetService(“Players”)
local Part = script.Parent
Part.Touched:Connect(function(Hit)
local Plr = Players:GetPlayerFromCharacter(Hit.Parent) or Players:GetPlayerFromCharacter(Hit.Parent.Parent)
if Plr then
Plr.Backpack.Folder.FIGHT.Value = true
Plr.Backpack.Folder.enemy.Value = 1
wait(3)
print(“a”)
end
end)
local Players = game:GetService("Players")
local Backpack = Players.LocalPlayer:WaitForChild("Backpack")
while task.wait(1) do
if Backpack.Folder.FIGHT.Value == true then
print("true")
else print("false")
end
end
This is looped to check if its false or not. This should work now