I created a typewriting effect, and its supposed to only work locally, but when I tested it, It worked for both players. 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("TriggerPart1")
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, "test test test test")
wait(#"hello hi" * 0.1)
Frame.Visible = false
wait(0)
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local TriggerPart = workspace:WaitForChild("TriggerPart1")
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] and player == Player then
typewritingTriggered[player] = true
Frame.Visible = true
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
AutoType(script.Parent, "test test test test")
wait(#"hello hi" * 0.1)
Frame.Visible = false
wait(0)
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end)
Ok so I adjusted the process a little bit, I created a remote event named TypewritingEvent, and I created a server side script and adjusted the local script, it works for the first typewriting effect, but I dont know how to make it work for the others, Here is my serverside script (handles the 1st typewriting effect):
local TriggerPart = workspace:WaitForChild("TriggerPart1")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TypewritingEvent = ReplicatedStorage:WaitForChild("TypewritingEvent")
TriggerPart.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
TypewritingEvent:FireClient(player, "test test test test")
end
end)
And here is my LocalScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TypewritingEvent = ReplicatedStorage:WaitForChild("TypewritingEvent")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Frame = script.Parent.Parent
local typewritingTriggered = {}
function AutoType(textLabel, message)
for i = 1, #message do
textLabel.Text = string.sub(message, 1, i)
wait(0.07)
script.Sound:Play()
end
end
TypewritingEvent.OnClientEvent:Connect(function(message)
if not typewritingTriggered[Player] then
typewritingTriggered[Player] = true
Frame.Visible = true
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
AutoType(script.Parent, message)
wait(#"hello hi" * 0.1)
Frame.Visible = false
wait(0)
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end)
Could you help me adjust the scripts to make it work for each typewriting effect
AutoType(script.Parent, "hello im from saudi arabia")
wait(#"hello hi" * 1) -- wtf is this???
AutoType(script.Parent, "im here to take your 20 million barrel of oil")