Hello! I have a messaging system which basically is a gui system where you can “message” player alerts, objectives, or achievements In fact, it’s more of an achievement system as you see in minecraft.
In order to message the player, you have to fire a remote event, which contains 2 parameters: title and message. These are two string values which will change the 2 text labels in the message system.
So the problem is that whenever I fire the remote event, it says “unable to cast value to object” in the gui script where it displays everything.
Heres the code:
-- Variables
local Main = script.Parent
local TitleFrame = script.Parent["Title Frame"]
local Message = Main.MessageText
local Title = TitleFrame.MessageTitle
-- Function Set up
local function resetMessageProperties()
Main.Visible = false
-- Main Frame
Main.Size = UDim2.new(0.35, 0,0.3, 0)
Main.Position = UDim2.new(-0.015,0 , 0,0)
Main.ZIndex = 1
-- Title Frame
TitleFrame.Size = UDim2.new(0.8,0 , 0.5,0)
TitleFrame.Position = UDim2.new(0,0,0,0)
TitleFrame.ZIndex = 2
-- Message Text
Message.Size = UDim2.new(0.9, 0,0.35, 0)
Message.Position = UDim2.new(0.048,0,0.6,0)
Message.Text = "message"
TitleFrame.ZIndex = 2
-- Title Text
Title.Size = UDim2.new(0.9,0,0.85,0)
Title.Position = UDim2.new(0.048, 0,0.061, 0)
Title.Text = "Alert"
TitleFrame.ZIndex = 3
end
local function playMessageAnimation(animtype)
if animtype == 1 then
Main.Position = UDim2.new(-0.078, 0,0, 0)
Main:TweenPosition(UDim2.new(-0.015,0 , 0,0), Enum.EasingDirection.In, Enum.EasingStyle.Sine, .1, false)
else
Main.Position = UDim2.new(-0.015,0 , 0,0)
Main:TweenPosition(UDim2.new(-0.078, 0,0, 0), Enum.EasingDirection.In, Enum.EasingStyle.Sine, .1, false)
end
end
game.ReplicatedStorage.MessageClient.OnClientEvent:Connect(function(title, message)
resetMessageProperties()
Message.Text = message
Title.Text = title
Main.Visible = true
playMessageAnimation(1)
wait(2)
playMessageAnimation(2)
wait(0.1)
resetMessageProperties()
end)
Thanks!