So I’ve run into an issue. I’m creating a framework for my upcoming battlegrounds game and everything was going smoothly and working perfectly until I published it for my playtesters to test. It turns out that when one person uses a move, everyone else in the server does as well. I know why but I dont know how to fix it. Here is my code:
in StarterCharacterScripts as a server script.
--Mind my HORRIBLE coding method. This is my first fightning game.
local RepStore = game:GetService("ReplicatedStorage")
local GameCharacter = RepStore.Characters.PlaceholderMoveset
local AssetsFolder = GameCharacter.Assets
local VFXFolder = AssetsFolder.VFX
local AnimsFolder = AssetsFolder.Animations
local RemotesFolder = GameCharacter.Remotes
local HitboxesFolder = GameCharacter.Hitboxes
local Stunned = script.Parent:WaitForChild("Stunned")
local Move1Anim = script.Parent.Humanoid:LoadAnimation(AnimsFolder.Move1Anim)
local Move1Remote = RemotesFolder.Move1
local Move2Remote = RemotesFolder.Move2
local Move3Remote = RemotesFolder.Move3
local Move4Remote = RemotesFolder.Move4
local Hitbox1 = HitboxesFolder.Hitbox1
Move1Remote.OnServerEvent:Connect(function()
Stunned.Value = "true"
local VFX = VFXFolder.Placeholder1:Clone()
local Hitbox = Hitbox1:Clone()
Hitbox.User.Value = script.Parent.Name
script.Parent.Humanoid.JumpPower = 0
script.Parent.Humanoid.WalkSpeed = 0
script.Parent.Humanoid.AutoRotate = false
Move1Anim:Play()
wait(1.4)
script.Parent.Humanoid.AutoRotate = false
VFX.Parent = workspace.VFX
VFX.CFrame = script.Parent.HumanoidRootPart.CFrame * CFrame.new(0,0,-10)
Hitbox.Parent = workspace
Hitbox.CFrame = script.Parent.HumanoidRootPart.CFrame * CFrame.new(0,0,-10)
for i,v in pairs(workspace:GetPartsInPart(Hitbox)) do
if v.Parent:FindFirstChild("Humanoid") and v.Parent ~= script.Parent and v.Parent:FindFirstChild("Hit"..script.Parent.Name) == nil then
local x = Instance.new("IntValue", v.Parent)
x.Name = "Hit"..script.Parent.Name
game.Debris:AddItem(x, 1)
v.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
end
end
wait(0.1)
VFX.Attachment.ParticleEmitter:Emit(20)
Hitbox:Destroy()
wait(1.5)
Move1Anim:Stop()
script.Parent.Humanoid.JumpPower = 50
script.Parent.Humanoid.WalkSpeed = 16
script.Parent.Humanoid.AutoRotate = true
wait(0.5)
Stunned.Value = "false"
wait(10)
VFX:Destroy()
end)
local script inside the tool that is fires the event:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerCharacter = Player.Character
local Stunned = PlayerCharacter:WaitForChild("Stunned")
local CD = 8
local Passtimes = CD
local OnCD = false
local MoveName = "Move1"
script.Parent.Activated:Connect(function()
if OnCD == false then
if Stunned.Value == "false" then
OnCD = true
game.ReplicatedStorage.Characters.TheStronkestCat.Remotes.Move1:FireServer()
while true do
script.Parent.Name = Passtimes
wait(1)
Passtimes = Passtimes - 1
if Passtimes == 0 then
Passtimes = CD
OnCD = false
script.Parent.Name = MoveName
break
end
end
end
end
end)
and finally, the server script in ServerScriptService that gives the player the Stunned string value (you didn’t really need to know this one but I thought I’d just add it in so you know that its there.):
--I know I know. There are much better ways to do stuff like this.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local Value = game.ReplicatedStorage.Values.Stunned
Value:Clone().Parent = character
end)
end)
If anyone could help that would be HUGE. Thanks!