Script suddenly stopped working after other script fired?
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):
01 | local textInterval = 0.05 |
04 | local plr = game.Players.LocalPlayer |
07 | function talkDialog(text) |
09 | if isOldMan = = true then |
10 | local click = Instance.new( "Sound" ,workspace.OldManMushroomShopkeeper 1. Torso.TalkPart) |
12 | click.RollOffMaxDistance = 50 |
13 | click.RollOffMinDistance = 15 |
14 | click.PlaybackSpeed = 0.3 |
15 | click.RollOffMode = Enum.RollOffMode.InverseTapered |
17 | click.Ended:Connect( function () |
20 | plr.PlayerGui.OldMansDialog.OldManDialogFrame:WaitForChild( "Text" ).Text = string.sub(text, 1 ,i) |
21 | elseif isDad = = true then |
22 | local clickDad = Instance.new( "Sound" ,workspace [ "Paps (Dad)" ] .Torso) |
24 | clickDad.RollOffMaxDistance = 100 |
25 | clickDad.RollOffMinDistance = 40 |
26 | clickDad.PlaybackSpeed = 0.7 |
27 | clickDad.RollOffMode = Enum.RollOffMode.InverseTapered |
29 | plr.PlayerGui.DadDialog.DadDialogFrame:WaitForChild( "Text" ).Text = string.sub(text, 1 ,i) |
35 | workspace.OldManMushroomShopkeeper 1. Torso.TalkPart.ProximityPrompt.Triggered:Connect( function () |
36 | if debounce = = false then |
38 | game.ReplicatedStorage.FreezePlayer:FireServer(plr) |
39 | plr.PlayerGui.OldMansDialog.Enabled = true |
41 | talkDialog( "Hey there, boy... feel free to purchase an item." ) |
43 | talkDialog( "This shop isnt finished yet. Do not expect working items." ) |
45 | plr.PlayerGui.OldMansDialog.Enabled = false |
46 | game.ReplicatedStorage.UnfreezePlayer:FireServer(plr) |
52 | workspace [ "Paps (Dad)" ] .Torso.ProximityPrompt.Triggered:Connect( function () |
53 | local amounttalkedto = 0 |
54 | if debounce = = false then |
58 | if amounttalkedto = = 0 and used = = false and workspace.DadAsked.Value = = false and workspace.HasPackedWind.Value = = false then |
59 | game.ReplicatedStorage.FreezePlayer:FireServer(plr) |
61 | plr.PlayerGui.DadDialog.Enabled = true |
62 | 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." ) |
64 | workspace.DadAsked.Value = true |
65 | plr.PlayerGui.DadDialog.Enabled = false |
66 | game.ReplicatedStorage.UnfreezePlayer:FireServer(plr) |
69 | if workspace.DadAsked.Value = = true and workspace.HasPackedWind.Value |
71 | game.ReplicatedStorage.FreezePlayer:FireServer(plr) |
72 | plr.PlayerGui.DadDialog.Enabled = true |
73 | talkDialog( "Thanks son! I'll go and wait for you in the next area." ) |
75 | game.ReplicatedStorage.DestroyPart:FireServer(plr) |
76 | plr.PlayerGui.DadDialog.Enabled = false |
77 | plr.Character.Humanoid.WalkSpeed = 16 |
78 | plr.Character.HumanoidRootPart.Anchored = false |
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:
1 | game.ReplicatedStorage.DestroyPart:FireServer(plr) |
Here is the script in ServerScriptService (The script that isnt working):
01 | local TS = game:GetService( "TweenService" ) |
03 | local Info = TweenInfo.new( 1 ,Enum.EasingStyle.Linear,Enum.EasingDirection.In, 0 , false , 0 ) |
05 | local newBackgroundTransparency 1 = { |
06 | BackgroundTransparency = 0 |
08 | local newBackgroundTransparency 2 = { |
09 | BackgroundTransparency = 1 |
19 | function enterBoat(hit) |
20 | if debounce = = false then |
22 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
24 | local hum = hit.Parent:FindFirstChild( "Humanoid" ) |
25 | local humroot = hit.Parent:FindFirstChild( "HumanoidRootPart" ) |
26 | local plr = game.Players:GetPlayerFromCharacter(hit.Parent) |
27 | humroot.CFrame = workspace.Boat 1. EnterBoat.CFrame |
28 | print ( "start moving boat!" ) |
31 | plr.PlayerGui.Black.BlackFrame.Visible = true |
32 | plr.PlayerGui.Black.BlackFrame.BackgroundTransparency = 1 |
33 | workspace.Boat 1. WeldPart.sea:Play() |
34 | local tween 3 = TS:Create(workspace.Boat 1. WeldPart.sea,Info,newVolume 1 ) |
36 | local tween 1 = TS:Create(plr.PlayerGui.Black.BlackFrame,Info,newBackgroundTransparency 1 ) |
38 | print ( "tween playing" ) |
39 | tween 1. Completed:Connect( function () |
40 | local tween 4 = TS:Create(workspace.Boat 1. WeldPart.sea,Info,newVolume 2 ) |
42 | tween 4. Completed:Connect( function () |
43 | workspace.Boat 1. WeldPart.sea:Stop() |
48 | local tween 2 = TS:Create(plr.PlayerGui.Black.BlackFrame,Info,newBackgroundTransparency 2 ) |
51 | humroot.CFrame = workspace.Area 2 TP.CFrame * CFrame.new( 0 , 3 , 0 ) |
52 | workspace.Boat 1. WeldPart.Position = Vector 3. new( 219.506 , 0.03 , - 180.014 ) |
60 | 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:
1 | game.ReplicatedStorage.FreezePlayer.OnServerEvent:Connect( function (plr) |
2 | plr.Character.Humanoid.WalkSpeed = 0 |
3 | plr.Character.HumanoidRootPart.Anchored = true |
6 | game.ReplicatedStorage.UnfreezePlayer.OnServerEvent:Connect( function (plr) |
7 | plr.Character.Humanoid.WalkSpeed = 16 |
8 | plr.Character.HumanoidRootPart.Anchored = false |
I feel like the RemoteEvents script is unneccassary to show, but its there anyway.
Any help would be appreciated. Thanks!