Hello! I want to create a script that will change the players walk speed when they hit it (For now it should just print something). It should be pretty simple and I have a very similar script that pops up a UI when a player touches it (Uses the same method I am trying with the new one I am trying to create).
The new one (when you touch it the players speed increases) is not working for some reason and it is copy and pasted from the working one just with a couple of changes so it does not pop up the UI when touched.
Please can anyone help me in why this is not working as I cannot find anything wrong with it. It is giving me no errors in the output.
(Sorry if it is a simple fix or error I am pretty new to scripting on roblox)
New Code (Not working):
local Players = game:GetService("Players")
local queueLine = false
local touchPart = script.Parent
touchPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
if queueLine == false then
print("Player has entered the queue line!")
end
end
end
end)
Old code (Working):
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local debounce = false
local touchPart = game.Workspace.ApocTeleportPart
local apocTeleportNotification = script.Parent
local notificationSound = script.Parent.NotificationSound
local tweenEndPosition = UDim2.new(0.01, 0, 0.835, 0)
local tweenInfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out
)
local notificationTweenON = TweenService:Create(apocTeleportNotification, tweenInfo, {Position = tweenEndPosition})
touchPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
if debounce == false then
print("Player has stepped on teleport plate!")
apocTeleportNotification.Visible = true
notificationTweenON:Play()
notificationSound:Play()
debounce = true
wait(5)
debounce = false
apocTeleportNotification.Visible = false
end
end
end
end)
Cheers