Hey, I’m having some issues with this dash script.
Basically whats erroring is the render function, for some reason.
if anyone knows why, please let me know.
--// SERVICES
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
--// VARIABLES
local DashFolder = ReplicatedStorage:WaitForChild("Dash")
local DashRemote = DashFolder:WaitForChild("Dash")
local Player = Players.LocalPlayer
--// FUNCTIONS
task.wait(5)
-->> Get Device
function GetDevice()
if GuiService:IsTenFootInterface() then
return "Console"
elseif UserInputService.TouchEnabled and not UserInputService.MouseEnabled then
return "Mobile"
else
return "Desktop"
end
end
-->> Activated
function Activated()
DashRemote:Fire()
end
script.Parent.Activated:Connect(Activated)
-->> Render
function Render()
local Device = GetDevice()
if Device == "Desktop" then
if Player then
if tonumber(Player:GetAttribute("Dash")) ~= nil then
if Player:GetAttribute("Dash") <= 0 then
script.Parent.Text = "Dash - " .. tostring(Player:GetAttribute("DashKey"))
else
script.Parent.Text = "Dash - " .. tostring(Player:GetAttribute("Dash")) .. "s"
end
end
end
end
end
RunService.RenderStepped:Connect(Render)
It’s the “if Player then” line.
It’s meant to be “if player ~= nil then”
This is because in an if statement you can only exclude the equals mark if the variable your using is true or false (A boolean).
The player is either the player itself (game.Players.PlayerName) or nil
So if you don’t want that part of the script to run when the player doesn’t exist you just have to make sure the player isn’t nil