I am creating a game the players have the ability to shoot ropes and swing. I am currently working on a system that will determine if the player can shoot a rope. There is a function that triggers when a player join that assigns then remote events and number/bool values. The folder that contains the player events/values is located under the replicated storage. The client reads the variables to determine if it can trigger the remote event to preform an action. Then the server writes over the variables in the replicated storage creating a debounce so the player cannot fire a second tether while the first is still out. However the server cannot seem to update the values when its code gets fired. If I manually look on the variable it is supposed to update it is the same on both the server and client.
Here is a small portion of the code that creates the player stats
local function SetUp(Player)
local PlayerFolder = Instance.new("Folder",game.ReplicatedStorage.PlayerInfo) --Creates main player folder PlayerFolder.Name = Player.Name .. "InfoFolder"
local PlayerEvents = Instance.new("Folder",PlayerFolder) --Creates a sub folder PlayerEvents.Name = "PlayerEvents"
local TetherMovementEvent = Instance.new("RemoteEvent",PlayerEvents) --Creates a player event TetherMovementEvent.Name = "TetherMovement"
local TriggerRope = Instance.new("RemoteEvent",PlayerEvents) --Creates a player event TriggerRope.Name = "TriggerRope"
local TriggerSpring = Instance.new("RemoteEvent",PlayerEvents) --Creates a player event TriggerSpring.Name = "TriggerSpring"
local TriggerFist = Instance.new("RemoteEvent",PlayerEvents) --Creates a player event TriggerFist.Name = "TriggerFist"
local TriggerSpecial = Instance.new("RemoteEvent",PlayerEvents) --Creates a player event TriggerSpecial.Name = "TriggerSpecial"
local PlayerValues = Instance.new("Folder",PlayerFolder) --Creates a sub folder PlayerValues.Name = "PlayerValues"
local TetheredRope = Instance.new("BoolValue",PlayerValues) --Creates a player value TetheredRope.Name = "TetheredRope"
local TetheredSpring = Instance.new("BoolValue",PlayerValues) --Creates a player value TetheredSpring.Name = "TetheredSpring"
Etc
game.Players.PlayerAdded:Connect(SetUp)
Basically there is a folder in the replicated storage called player info. A new folder is created under it that contains that one player stats and it includes the players name so it can be found easily if there are multiple players online at once. Then inside that folder two more are created that house player specific event and player specific variables objects.
Here is the local code for the player that triggers the event
local Player = game.Players.LocalPlayer local mouse = Player:GetMouse() local Debounce = false
local PlayerInfo = game.ReplicatedStorage.PlayerInfo local PlayerFolder = PlayerInfo:FindFirstChild(Player.Name .. "InfoFolder") --Defines variables for convince local EventFolder = PlayerFolder:FindFirstChild("PlayerEvents") local TriggerRopeEvent = EventFolder:FindFirstChild("TriggerRope") local ValueFolder = PlayerFolder:FindFirstChild("PlayerValues") local CanCastRopeValue = ValueFolder:FindFirstChild("CanCastRope").Value local TetheredRopeValue = ValueFolder:FindFirstChild("TetheredRope").Value local StunnedValue = ValueFolder:FindFirstChild("Stunned").Value local OnFloorValue = ValueFolder:FindFirstChild("OnFloor").Value
local function fire()
if CanCastRopeValue == true and TetheredRopeValue == false and StunnedValue == false and OnFloorValue == false then
local PlayerName = Player.Name local Character = game.Workspace:FindFirstChild(PlayerName) --Define varaibles local mousepos = mouse.Hit.Position
TriggerRopeEvent:FireServer(Character,mousepos,mouse.Target) --Character:FindFirstChild("Humanoid").PlatformStand = true
end
end
mouse.Button2Up:Connect(fire)
Basically the variables in the front define the player specific object variables and the local script will only fire server if those variables are set in a specific way.
Here is the server script side script that corresponds to this.
local Player = script.Parent:FindFirstChild("PlayerValue").Value local PlayerInfo = game.ReplicatedStorage.PlayerInfo local PlayerFolder = PlayerInfo:FindFirstChild(Player.Name .. "InfoFolder") --Defines variables for convince local EventFolder = PlayerFolder:FindFirstChild("PlayerEvents") local TriggerRopeEvent = EventFolder:FindFirstChild("TriggerRope") local ValueFolder = PlayerFolder:FindFirstChild("PlayerValues") local TetheredValue = ValueFolder:FindFirstChild("TetheredRope").Value local CanCastRopeValue = ValueFolder:FindFirstChild("CanCastRope").Value local RopeScript = game.ServerStorage.ReplicatedObjectScripts.RopeScript
local function fire(sans,Playerobject,MousePos,TargetValue)
CanCastRopeValue = false
local projectile = Instance.new("Part",game.Workspace) projectile.CanCollide = false projectile.Position = Playerobject:FindFirstChild("HumanoidRootPart").Position --Creates the part projectile.Anchored = true projectile.Size = Vector3.new(0.01,0.01,0.01) projectile.Transparency = 1
local clone = RopeScript:Clone() --Clones script for projectile clone.Parent = projectile
clone:FindFirstChild("Destination").Value = MousePos clone:FindFirstChild("PlayerValue").Value = Playerobject clone:FindFirstChild("TargetValue").Value = TargetValue clone.Disabled = false
TetheredValue = true
end
TriggerRopeEvent.OnServerEvent:Connect(fire)
Note this script is duplicated for every player by the first script mentioned above. The player variable is set to the player model located in the workspace.
You will also notice that the line of code right before end is 'TetheredValue = true". However this line of code does not update the bool value on either the client or server. I have no idea what is causing this problem and why it is not updating.
Also sorry for the variable lines above being a mess. The program just edits it that way when previewed it does not look like that when I was typing out this.

1 comment
use the lua "code block" button to format your code so its readable