I created a typewriting effect, and i want to make it so a player is only allowed to get the typewriting effect once. But when a player resets their character, they are able to get the typewriting effect again.I tried editing the script (my knowledge in scripting is very limited) and I wasn’t able to achieve what I wanted to achieve. I don’t know where to start, could somebody help? Ive been having this issue for over a week and I dont have any idea on how to resolve it. Here is my script:
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild(“Humanoid”)
local TriggerPart = workspace:WaitForChild(“TriggerPart”)
local Frame = script.Parent.Parent
local typewritingTriggered = {}
function AutoType(textLabel, message)
for i = 1, #message do
textLabel.Text = string.sub(message, 1, i)
task.wait(0.07)
script.Sound:Play()
end
end
TriggerPart.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and not typewritingTriggered[player] then
typewritingTriggered[player] = true
Frame.Visible = true
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
AutoType(script.Parent, "The evil dentist has gone crazy! Let's try and find a way to escape!")
wait(#"hello hi" * 0.1)
Frame.Visible = false
wait(0)
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end)
Make a server script and put it in ServerScriptService
local Event = game.ReplicatedStorage.EVENT --Make an event and put it in ReplicatedStorage and change 'EVENT' to the name of the event
game:GetService('Players').PlayerAdded:Connect(function(plr)
Event:FireClient(plr) --Fires the event to the client (This will only happen once....when the player joins the server)
end)
Then, you just need to simply add the Event into your local script.
local Event = game.ReplicatedStorage.EVENT --Change 'EVENT' to the name of the event
Event.OnClientEvent:Connect(function() --Happens when the event is fired (it will only happen once...when the player joins the server
PUT YOUR CODE HERE!!!
AutoType(script.Parent, "The evil dentist has gone crazy! Let's try and find a way to escape!")
wait(#"hello hi" * 0.1)
Frame.Visible = false
wait(0)
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end)
There might be a few spelling mistakes here, so let me know if it works
Alright, so I adjusted my scripts and now it doesn’t work. here is what I ended up with (also how do I get that script text for whenever I type a script on devforum)
ServerScriptService script:
local Event = game.ReplicatedStorage.StupidEvent --Make an event and put it in ReplicatedStorage and change ‘EVENT’ to the name of the event
Event:FireClient(plr) --Fires the event to the client (This will only happen once....when the player joins the server)
end)
LocalScript:
local Event = game.ReplicatedStorage.StupidEvent
Event.OnClientEvent:Connect(function()
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild(“Humanoid”)
local TriggerPart = workspace:WaitForChild(“TriggerPart123”)
local Frame = script.Parent.Parent
local typewritingTriggered = {}
function AutoType(textLabel, message)
for i = 1, #message do
textLabel.Text = string.sub(message, 1, i)
task.wait(0.07)
script.Sound:Play()
end
end
TriggerPart.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and not typewritingTriggered[player] then
typewritingTriggered[player] = true
Frame.Visible = true
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
AutoType(script.Parent, "The evil dentist has gone crazy! Let's try and find a way to escape!")
wait(#"hello hi" * 0.1)
Frame.Visible = false
wait(0)
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
local Event = game.ReplicatedStorage.StupidEvent
Event.OnClientEvent:Connect(function()
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local TriggerPart = workspace:WaitForChild("TriggerPart123")
local Frame = script.Parent.Parent
local typewritingTriggered = {}
function AutoType(textLabel, message)
for i = 1, #message do
textLabel.Text = string.sub(message, 1, i)
task.wait(0.07)
script.Sound:Play()
end
end
TriggerPart.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and not typewritingTriggered[player] then
typewritingTriggered[player] = true
Frame.Visible = true
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
AutoType(script.Parent, "The evil dentist has gone crazy! Let's try and find a way to escape!")
wait(#"hello hi" * 0.1)
Frame.Visible = false
wait(0)
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end)
local Event = game.ReplicatedStorage.StupidEvent
Event.OnClientEvent:Connect(function()
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local TriggerPart = workspace:WaitForChild("TriggerPart123")
local Frame = script.Parent.Parent
local typewritingTriggered = {}
function AutoType(textLabel, message)
for i = 1, #message do
textLabel.Text = string.sub(message, 1, i)
task.wait(0.07)
script.Sound:Play()
end
end
TriggerPart.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and not typewritingTriggered[player] then
typewritingTriggered[player] = true
Frame.Visible = true
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
AutoType(script.Parent, "The evil dentist has gone crazy! Let's try and find a way to escape!")
wait(#"hello hi" * 0.1)
Frame.Visible = false
wait(0)
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end)
end)