Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Unexpected bug encountered when executing a script with no errors?

Asked by 3 years ago

Hello, I tried to make it so that if you say “nad is sus” I get flinged. When I said “nad is sus” in the chat, I didn’t get flinged. There was no error. Here’s the script:

game.Players.yariel19831.Chatted:Connect(function(msg)
if MSG == "nad is sus" then
local m = Instance.new("Message",game.Workspace)
local OriginalForce = game.Workspace.Naderssrr.HumanoidRootPart:GetMass()
m.Text = " "
wait()
power = 50000
local bambam = Instance.new("BodyThrust")
bambam.Parent = game.Workspace.Naderssrr.HumanoidRootPart
bambam.Force = Vector3.new(power,0,power)
bambam.Location = game.Workspace.Naderssrr.HumanoidRootPart.Position
game.Workspace.Naderssrr.Humanoid.Sit = true
local bodyForce = Instance.new('BodyForce', game.Workspace.Naderssrr.HumanoidRootPart)
bodyForce.Name = 'NoGravity'
bodyForce.force = Vector3.new(0, OriginalForce, 0)
wait(0.3)
wait(2)
-- WARNING: Be sure to make this a Script and place it in Workspace if you want it to work!
local sound = Instance.new("Sound")
sound.Name = "Sound"
sound.SoundId = "http://www.roblox.com/asset/?id=5763626926" -- Song ID at end.
sound.Volume = 10 -- Derp (I have quality speakers you might need to change this.)
sound.Pitch = 1 --Speed of Playback.
sound.Looped = true
sound.archivable = false
sound.Parent = game.Workspace
wait()
sound:play()
wait()
m.Text = "N"
wait(0.1)
m.Text = "Na"
wait(0.1)
m.Text = "Nad"
wait(0.1)
m.Text = "Nade"
wait(0.1)
m.Text = "Nader"
wait(0.1)
m.Text = "Naders"
wait(0.1)
m.Text = "Naderss"
wait(0.1)
m.Text = "Naderssr"
wait(0.1)
m.Text = "Naderssrr"
wait(0.1)
m.Text = "Naderssrr w"
wait(0.1)
m.Text = "Naderssrr wa"
wait(0.1)
m.Text = "Naderssrr was"
wait(0.1)
m.Text = "Naderssrr was e"
wait(0.1)
m.Text = "Naderssrr was ej"
wait(0.1)
m.Text = "Naderssrr was eje"
wait(0.1)
m.Text = "Naderssrr was ejec"
wait(0.1)
m.Text = "Naderssrr was eject"
wait(0.1)
m.Text = "Naderssrr was ejecte"
wait(0.1)
m.Text = "Naderssrr was ejected"
wait(0.1)
m.Text = "Naderssrr was ejected."
wait(0.1)
sound:Remove()
wait(2)
m.Text = "Naderssrr was ejected. 1 impostor still remain."
wait(2)
m.Text = " "
wait(0.7)
m:remove()
end
end)

Please help me. I feel like I’m in absurd when scripts doesn’t execute.

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

The first thing I can see is that you didn't write "msg" in lowercase like in your chatted event, consider changing that to "msg" instead of "MSG".

Like this:

game.Players.yariel19831.Chatted:Connect(function(msg)
if msg == "nad is sus" then
-- run your code here

Also, you don't need to write the message and wait 0.1 seconds.

Instead, use a for loop and use string.sub() to display the message.

Like this:

sound.Parent = game.Workspace
local messageToDisplay = "Naderssrr was ejected."
wait()
for i = 1, #messageToDisplay, 1 do
   m.Text = string.sub(messageToDisplay, 1, i)
   sound:Play()
wait(0.1)
end
wait(0.1)
sound:Remove()
wait(2)
m.Text = "Naderssrr was ejected. 1 impostor still remains."
wait(2)
m.Text = ""
wait(0.7)
m:Remove()

So your final script should look a bit like this:

game.Players.yariel19831.Chatted:Connect(function(msg)
if msg == "nad is sus" then
local m = Instance.new("Message",game.Workspace)
local OriginalForce = game.Workspace.Naderssrr.HumanoidRootPart:GetMass()
m.Text = " "
wait()
power = 50000
local bambam = Instance.new("BodyThrust")
bambam.Parent = game.Workspace.Naderssrr.HumanoidRootPart
bambam.Force = Vector3.new(power,0,power)
bambam.Location = game.Workspace.Naderssrr.HumanoidRootPart.Position
game.Workspace.Naderssrr.Humanoid.Sit = true
local bodyForce = Instance.new('BodyForce', game.Workspace.Naderssrr.HumanoidRootPart)
bodyForce.Name = 'NoGravity'
bodyForce.force = Vector3.new(0, OriginalForce, 0)
wait(0.3)
wait(2)
-- WARNING: Be sure to make this a Script and place it in Workspace if you want it to work!
local sound = Instance.new("Sound")
sound.Name = "Sound"
sound.SoundId = "http://www.roblox.com/asset/?id=5763626926" -- Song ID at end.
sound.Volume = 10 -- Derp (I have quality speakers you might need to change this.)
sound.Pitch = 1 --Speed of Playback.
sound.Looped = true
sound.archivable = false
sound.Parent = game.Workspace
local messageToDisplay = "Naderssrr was ejected."
wait()
for i = 1, #messageToDisplay, 1 do
   m.Text = string.sub(messageToDisplay, 1, i)
   sound:Play()
wait(0.1)
end
wait(0.1)
sound:Remove()
wait(2)
m.Text = "Naderssrr was ejected. 1 impostor still remains."
wait(2)
m.Text = ""
wait(0.7)
m:Remove()
end
end)
0
It works! Thanks a lot! Naderssrr 15 — 3y
0
Glad I could help! Green_Lime2 80 — 3y
Ad

Answer this question