You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? When pressing Q (located in a different script), an animation plays. There are two bats: welded to the player’s hand and welded to the player’s backpack. Depending if it’s being equipped or unequipped, one goes transparent and the other goes visible.
I also have another script that handles creating a boolvalue, named after the player, and goes true or false depending on whether the bat in the player’s hand is transparent or not. It is located inside a folder named PlayerEquips (see below)
game.Players.PlayerAdded:Connect(function(player)
local playername = player.Name
local val = Instance.new("BoolValue")
val.Name = playername
val.Parent = game.ServerStorage.PlayerEquips
wait(0.25)
if player.Character:WaitForChild("HandBaseballBat").Transparency == 1 then
val.Value = false
if player.Character:WaitForChild("HandBaseballBat").Transparency == 0 then
val.Value = true
end
end
end)
-
What is the issue? The event in ReplicatedStorage is firing (it prints in the output), however, it does not print that the signal is being received, and no further code in the script runs.
-
What solutions have you tried so far? I’ve searched DevForum and have found similar posts and issues, however, none of the solutions worked for me.
Here’s my script:
debounce = false
local anim1 = script.GetBat
local anim2 = script.Unequip
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BatEvent = ReplicatedStorage.Events:WaitForChild("BatEquipped")
game.Players.PlayerAdded:Connect(function(player)
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChild('Humanoid')
local handbat = Character.HandBaseballBat
local backbat = Character.BackBaseballBat
local equipped = game.ServerStorage.PlayerEquips:WaitForChild(player.Name)
local function BatEventFired()
print("The signal to Equip was received!")
if handbat.Transparency == 1 then
if equipped.Value == false then
debounce = true
wait(0.1)
local Animation = Humanoid:LoadAnimation(anim1)
Animation:Play()
wait(0.85)
Character.HandBaseballBat.Transparency = 0
Character.BackBaseballBat.Transparency = 1
wait(1)
end
wait(1)
debounce = false
else
debounce = true
wait(0.1)
local Animation = Humanoid:LoadAnimation(anim2)
Animation:Play()
wait(0.85)
Character.HandBaseballBat.Transparency = 1
Character.BackBaseballBat.Transparency = 0
wait(1)
end
wait(1)
debounce = false
BatEvent.OnServerEvent:Connect(BatEventFired)
end
end)
Sorry this is long, I just feel like it needs a proper explanation of what’s going on.