You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I have 2 scripts that are similar to Jojos Bizzare Adventure; having stands, their attacks can be controlled by typing in the chat a few commands, but there are bugs that i want to fix -
What is the issue? Include screenshots / videos if possible!
LocalScript (placed in StarterPlayerScripts)
local TCS = game:GetService("TextChatService")
local player = game.Players.LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")
local standEvents = replicatedStorage:WaitForChild("StandEvents")
local mouse = player:GetMouse()
print("Listening for chat commands...")
-- Command dictionary
local chatCommands = {
["Behold.."] = function() standEvents.SummonStand:FireServer() end,
["Back down."] = function() standEvents.DesummonStand:FireServer() end,
["ORA ORA ORAA!!"] = function() standEvents.Barrage:FireServer() end,
["ORAA!!!"] = function() standEvents.HeavyPunch:FireServer() end,
["Take this!"] = function() standEvents.ThrowKnife:FireServer(mouse.Hit.Position) end,
["Ever seen something like this?!"] = function()
local target = mouse.Target
if target then
local targetPlayer = game.Players:GetPlayerFromCharacter(target.Parent)
if targetPlayer then
standEvents.HeadSlam:FireServer(targetPlayer)
end
end
end,
["Forget about time! No one needs time!"] = function() standEvents.TimeStop:FireServer() end,
["Heh.. Too slow."] = function() standEvents.TimeUnfreeze:FireServer() end,
["Yo! Come here for a sec?"] = function() standEvents.Pose:FireServer() end
}
local function processChatCommand(properties)
local message = properties.Text
print("Processing chat message: " .. message)
if chatCommands[message] then
print("Executing command for: " .. message)
chatCommands[message]()
else
print("No command found for message: " .. message)
end
end
TCS.OnIncomingMessage = processChatCommand
print("Chat command listener hooked.")
The LocalScript
does work perfectly; but I don’t think it is firing the Remote Event properly as nothing is being printed despite a print() added in the Script
which is below
Script (placed in ServerScriptService)
game.Loaded:Wait()
-- Services
local replicatedStorage = game:GetService("ReplicatedStorage")
local playersService = game:GetService("Players")
local standEvents = replicatedStorage:WaitForChild("StandEvents")
local TweenService = game:GetService("TweenService")
local standsFolder = workspace.ActiveStands
local standRig = replicatedStorage["Stand"]
repeat task.wait() until standRig
print("FoundStandRig")
repeat task.wait() until standsFolder
print("FoundStandFolder")
local playerStands = {}
local originalSpeeds = {}
local function createTween(part, targetCFrame, duration, easingStyle, easingDirection)
print("CreatedTween")
local tweenInfo = TweenInfo.new(duration, easingStyle, easingDirection)
local tweenGoal = {CFrame = targetCFrame}
local tween = TweenService:Create(part, tweenInfo, tweenGoal)
tween:Play()
return tween
end
local function tweenTransparency(part, targetTransparency, duration)
print("TweenTransparency")
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tweenGoal = {Transparency = targetTransparency}
local tween = TweenService:Create(part, tweenInfo, tweenGoal)
tween:Play()
end
-- Summon the stand
standEvents.SummonStand.OnServerEvent:Connect(function(player)
print("Received SummonStand event from " .. player.Name)
if not playerStands[player] then
print(player.Name .. " is summoning the stand.")
local success, em = pcall(function()
standClone = standRig:Clone()
end)
if success then
print('standrig cloned')
standClone.Parent = standsFolder
print('standrig parented?')
standClone:PivotTo(player.Character.HumanoidRootPart.CFrame * CFrame.new(3, 0, -3))
playerStands[player] = standClone
-- Summoning animation (fade in and slight movement)
for _, part in ipairs(standClone:GetChildren()) do
print("CheckingStandClonesChildren")
if part:IsA("BasePart") then
print("PartIsaPartLOL")
part.Transparency = 1
createTween(part, part.CFrame, 1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
game:GetService("TweenService"):Create(part, TweenInfo.new(1), {Transparency = 0}):Play()
print("Animation played")
end
end
else
print("Stand is already summoned for " .. player.Name)
end
end
end)
-- Desummon the Stand
standEvents.DesummonStand.OnServerEvent:Connect(function(player)
print("DesummonSignalRecieved")
local stand = playerStands[player]
if stand then
print("Found Stand For: " ..player.Name)
print(player.Name .. " is desummoning their Stand.")
-- Desummoning animation (fade out)
for index, part in ipairs(stand:GetChildren()) do
print(tostring(index), part.Name)
if part:IsA("BasePart") then
print("PartIsPart, Desummoning...")
tweenTransparency(part, 1, 1)
end
end
wait(1)
stand:Destroy()
playerStands[player] = nil
print("Desummoned")
else
print("No stand found for " .. player.Name)
end
end)
-- Barrage Attack
standEvents.Barrage.OnServerEvent:Connect(function(player)
print("Recieved Barrage Signal")
local stand = playerStands[player]
if stand then
print("Found Stand")
print(player.Name .. " is performing a barrage attack.")
local startPos = stand.PrimaryPart.CFrame
print("Head being utilized for CFrames animation tweening")
local barrageDuration = 4
local punchDuration = 0.2
local forwardPos = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -3)
local barrageTween = createTween(stand.PrimaryPart, forwardPos, barrageDuration, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
for i = 1, 20 do
createTween(stand.PrimaryPart, forwardPos * CFrame.new(0, 0, -0.5), punchDuration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
wait(0.2)
createTween(stand.PrimaryPart, forwardPos * CFrame.new(0, 0, 0.5), punchDuration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
wait(0.2)
end
barrageTween.Completed:Wait()
createTween(stand.PrimaryPart, startPos, 1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
else
print("No stand available for barrage attack.")
end
end)
-- Heavy Punch Attack
standEvents.HeavyPunch.OnServerEvent:Connect(function(player)
print('Event recieved')
local stand = playerStands[player]
if stand then
print(player.Name .. " is performing a heavy punch.")
local startPos = stand.PrimaryPart.CFrame
local punchPos = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5)
createTween(stand.PrimaryPart, punchPos, 0.5, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)
wait(0.5)
createTween(stand.PrimaryPart, startPos, 0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
else
print("No stand available for heavy punch.")
end
end)
-- Knife Throwing Attack
standEvents.ThrowKnife.OnServerEvent:Connect(function(player, mouseHitPos)
print('Event recieved')
local stand = playerStands[player]
if stand then
print(player.Name .. " is throwing knives.")
local startPos = stand.PrimaryPart.CFrame
local forwardPos = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -3)
createTween(stand.PrimaryPart, forwardPos, 0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
wait(0.5)
for i = 1, 5 do
local knife = Instance.new("Part")
knife.Size = Vector3.new(1, 0.2, 5)
knife.Shape = Enum.PartType.Block
knife.Color = Color3.new(0.8, 0.8, 0.8) -- Silver color
knife.Anchored = false
knife.CFrame = stand.PrimaryPart.CFrame * CFrame.new(0, 0, -i) -- Create knife behind stand
knife.Parent = workspace
local bodyVelocity = Instance.new("BodyVelocity", knife)
bodyVelocity.MaxForce = Vector3.new(1e6, 1e6, 1e6)
bodyVelocity.Velocity = (mouseHitPos - knife.Position).unit * 100 -- Throw speed
game.Debris:AddItem(knife, 5) -- Clean up knife after 5 seconds
print("knife cleaned up")
end
createTween(stand.PrimaryPart, startPos, 0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
print("knife thrown")
else
print("No stand available for knife throw.")
end
end)
-- Head Slam Logic
standEvents.HeadSlam.OnServerEvent:Connect(function(player, targetPlayer)
print("HeadSlam event recieved")
local stand = playerStands[player]
if stand and targetPlayer then
print(player.Name .. " is performing a head slam on " .. targetPlayer.Name)
-- Teleport stand to the target player
local targetRoot = targetPlayer.Character:FindFirstChild("HumanoidRootPart")
if targetRoot then
local standStartPos = stand.PrimaryPart.CFrame
stand:SetPrimaryPartCFrame(targetRoot.CFrame * CFrame.new(0, 5, 0)) -- Move stand above target
-- Hold and slam the target player
wait(0.5)
targetRoot.Anchored = true -- Freeze target during slam
local slamPos = targetRoot.CFrame * CFrame.new(0, -5, 0)
createTween(stand.PrimaryPart, slamPos, 0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
wait(0.5)
targetRoot.Anchored = false -- Unfreeze target after slam
-- Return the stand to its original position
createTween(stand.PrimaryPart, standStartPos, 1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
end
else
print("Head Slam failed: No target or no stand available.")
end
end)
-- Time Stop
standEvents.TimeStop.OnServerEvent:Connect(function(player)
print(player.Name .. " has stopped time.")
for _, plr in pairs(playersService:GetPlayers()) do
if plr.Character then
local humanoid = plr.Character:FindFirstChild("Humanoid")
if humanoid then
originalSpeeds[plr] = {WalkSpeed = humanoid.WalkSpeed, JumpPower = humanoid.JumpPower}
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
end
end
end
end)
-- Time Unfreeze
standEvents.TimeUnfreeze.OnServerEvent:Connect(function(player)
print(player.Name .. " has unfrozen time.")
for plr, speedInfo in pairs(originalSpeeds) do
if plr.Character then
local humanoid = plr.Character:FindFirstChild("Humanoid")
if humanoid then
humanoid.WalkSpeed = speedInfo.WalkSpeed or 16
humanoid.JumpPower = speedInfo.JumpPower or 50
end
end
end
originalSpeeds = {} -- Clear the stored speed info
end)
-- Pose Ability
standEvents.Pose.OnServerEvent:Connect(function(player)
local stand = playerStands[player]
if stand then
print(player.Name .. " is posing with the stand.")
-- Pose animation yet to be added
end
end)
Nothing prints in here, like absolutely nothing. standRig isn’t being cloned to ActiveStands
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Tried print statements and they work for the script initialization but not for the chat commands; other hacky ways (like UserInputService) but to no use as they dont work either.
I think it’s probably Remote Events not firing correctly; but ill let you devs decide.