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

Script suddenly stopped working after other script fired?

Asked by 2 years ago

I am trying to create a dialog in which a model talks and then eventually disappears. I did this and this worked, except for some reason when the model is destroyed, the SEPERATE script in ServerScriptService which has not been affected at all, no longer works. To make sure the dialog script was the problem, I moved the parts that prevented the player from walking by. The seperate script works perfectly, but when I put it back and let the script destroy it, it suddenly just doesnt work. I have checked my code plenty of times, yet it still hasnt worked. Here are the two scripts:

Dialog Script in StarterPack (its a LocalScript):

local textInterval = 0.05
local isOldMan = false
local isDad = false
local plr = game.Players.LocalPlayer
local debounce = false

function talkDialog(text)
    for i = 1, #text do
        if isOldMan == true then
            local click = Instance.new("Sound",workspace.OldManMushroomShopkeeper1.Torso.TalkPart)
            click.SoundId = "rbxassetid://410814187"
            click.RollOffMaxDistance = 50
            click.RollOffMinDistance = 15
            click.PlaybackSpeed = 0.3
            click.RollOffMode = Enum.RollOffMode.InverseTapered
            click:Play()
            click.Ended:Connect(function()
                click:Destroy()
            end)
            plr.PlayerGui.OldMansDialog.OldManDialogFrame:WaitForChild("Text").Text = string.sub(text,1,i)                                                  
        elseif isDad == true then
            local clickDad = Instance.new("Sound",workspace["Paps (Dad)"].Torso)
            clickDad.SoundId = "rbxassetid://449779138"
            clickDad.RollOffMaxDistance = 100
            clickDad.RollOffMinDistance = 40
            clickDad.PlaybackSpeed = 0.7
            clickDad.RollOffMode = Enum.RollOffMode.InverseTapered
            clickDad:Play()
            plr.PlayerGui.DadDialog.DadDialogFrame:WaitForChild("Text").Text = string.sub(text,1,i)
        end
        wait(textInterval)
    end
end

workspace.OldManMushroomShopkeeper1.Torso.TalkPart.ProximityPrompt.Triggered:Connect(function()
    if debounce == false then
        debounce = true
        game.ReplicatedStorage.FreezePlayer:FireServer(plr)
        plr.PlayerGui.OldMansDialog.Enabled = true
        isOldMan = true
        talkDialog("Hey there, boy... feel free to purchase an item.")
        wait(4)
        talkDialog("This shop isnt finished yet. Do not expect working items.")
        wait(3)
        plr.PlayerGui.OldMansDialog.Enabled = false
        game.ReplicatedStorage.UnfreezePlayer:FireServer(plr)
        debounce = false
        isOldMan = false
    end
end)

workspace["Paps (Dad)"].Torso.ProximityPrompt.Triggered:Connect(function()
    local amounttalkedto = 0
    if debounce == false then
        debounce = true
        isDad = true
        local used = false
        if amounttalkedto == 0 and used == false and workspace.DadAsked.Value == false and workspace.HasPackedWind.Value == false then
            game.ReplicatedStorage.FreezePlayer:FireServer(plr)
            used = true
            plr.PlayerGui.DadDialog.Enabled = true
            talkDialog("Hey there son! Do me a favor, will ya? Go get some packed up wind from the store to get ol' betsy here going.")
            wait(3)
            workspace.DadAsked.Value = true
            plr.PlayerGui.DadDialog.Enabled = false
            game.ReplicatedStorage.UnfreezePlayer:FireServer(plr)
            debounce = false
        else
            if workspace.DadAsked.Value == true and workspace.HasPackedWind.Value 
== true then
                game.ReplicatedStorage.FreezePlayer:FireServer(plr)
                plr.PlayerGui.DadDialog.Enabled = true
                talkDialog("Thanks son! I'll go and wait for you in the next area.")
                wait(3)
                game.ReplicatedStorage.DestroyPart:FireServer(plr)
                plr.PlayerGui.DadDialog.Enabled = false
                plr.Character.Humanoid.WalkSpeed = 16
                plr.Character.HumanoidRootPart.Anchored = false
            end
            debounce = false
        end
        amounttalkedto += 1
    end
end)

Sorry if this code is very poorly formatted, I dont know how to fix that or if it is fixable. The one that is working incorrectly is this line:

game.ReplicatedStorage.DestroyPart:FireServer(plr)

Here is the script in ServerScriptService (The script that isnt working):

local TS = game:GetService("TweenService")
local debounce = false
local Info = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0)

local newBackgroundTransparency1 = {
    BackgroundTransparency = 0
}
local newBackgroundTransparency2 = {
    BackgroundTransparency = 1
}
local newVolume1 = {
    Volume = .5
}
local newVolume2 = {
    Volume = 0
}


function enterBoat(hit)
    if debounce == false then
        if hit.Parent then
            if hit.Parent:FindFirstChild("Humanoid") then
                debounce = true
                local hum = hit.Parent:FindFirstChild("Humanoid")
                local humroot = hit.Parent:FindFirstChild("HumanoidRootPart")
                local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
                humroot.CFrame = workspace.Boat1.EnterBoat.CFrame
                print("start moving boat!")
                hum.JumpPower = 0
                wait(.5)
                plr.PlayerGui.Black.BlackFrame.Visible = true
                plr.PlayerGui.Black.BlackFrame.BackgroundTransparency = 1
                workspace.Boat1.WeldPart.sea:Play()
                local tween3 = TS:Create(workspace.Boat1.WeldPart.sea,Info,newVolume1)
                tween3:Play()
                local tween1 = TS:Create(plr.PlayerGui.Black.BlackFrame,Info,newBackgroundTransparency1)
                tween1:Play()
                print("tween playing")
                tween1.Completed:Connect(function()
                    local tween4 = TS:Create(workspace.Boat1.WeldPart.sea,Info,newVolume2)
                    tween4:Play()
                    tween4.Completed:Connect(function()
                        workspace.Boat1.WeldPart.sea:Stop()
                    end)
                    wait(2)
                    hum.JumpPower = 50
                    hum.Jump = true
                    local tween2 =              TS:Create(plr.PlayerGui.Black.BlackFrame,Info,newBackgroundTransparency2)
                    tween2:Play()
                    wait(.1)
                    humroot.CFrame = workspace.Area2TP.CFrame * CFrame.new(0,3,0)
                    workspace.Boat1.WeldPart.Position = Vector3.new(219.506, 0.03, -180.014)
                    debounce = false
                end)        
            end
        end
    end
end

workspace.EnterBoat.Touched:Connect(enterBoat)

I am new to ScriptingHelpers, sorry if I am doing this incorrectly. Here is the script with the RemoteEvents from the Dialog Script, which is in ServerScriptService:

game.ReplicatedStorage.FreezePlayer.OnServerEvent:Connect(function(plr)
    plr.Character.Humanoid.WalkSpeed = 0
    plr.Character.HumanoidRootPart.Anchored = true
end)

game.ReplicatedStorage.UnfreezePlayer.OnServerEvent:Connect(function(plr)
    plr.Character.Humanoid.WalkSpeed = 16
    plr.Character.HumanoidRootPart.Anchored = false
end)

I feel like the RemoteEvents script is unneccassary to show, but its there anyway. Any help would be appreciated. Thanks!

1 answer

Log in to vote
0
Answered by
xxaxxaz 42
2 years ago

you do not need a script for diolague. just do the original way.

0
Thank you for your reply. I will use this way in the future. LikeableEmmec 470 — 2y
Ad

Answer this question