What do you want to achieve? Keep it simple and clear!
Change the text on a gui depending on device type
What is the issue? Include screenshots / videos if possible!
It works perfectly in studio but flat out dosent in roblox player
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried switching what it checks for and different ways of checking but everytime it works perfect and studio and doesnt in player
local UserInputService = game:GetService("UserInputService")
workspace.ChildAdded:Connect(function(hit)
if game.Players:FindFirstChild(hit.Name) then
UserInputService.InputBegan:Connect(function(input)
print(1)
if UserInputService.TouchEnabled then
print(2)
players:GetPlayerFromCharacter(hit).PlayerGui.Freeze.TextLabel.Text = ("Tap")
end
end)
end
end)
If you change it to use CharacterAdded instead of doing workspace.ChildAdded, does it resolve the issue at all?
i.e.
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
UserInputService.InputBegan:Connect(function(input)
print(1)
if UserInputService.TouchEnabled then
print(2)
players:GetPlayerFromCharacter(hit).PlayerGui.Freeze.TextLabel.Text = ("Tap")
end
end)
or alternatively, if the local script doesn’t get reset when they die:
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local function CharacterAdded(char)
UserInputService.InputBegan:Connect(function(input)
print(1)
if UserInputService.TouchEnabled then
print(2)
players:GetPlayerFromCharacter(hit).PlayerGui.Freeze.TextLabel.Text = ("Tap")
end
end)
end
Player.CharacterAdded:Connect(CharacterAdded)
if Player.Character then
CharacterAdded(Player.Character)
end
If you add an additional print statement at the very top of the script, does it print out?
(Also, which variation of my code did you end up going with, the first one or the second one?)